Last active
December 25, 2015 12:37
-
-
Save ornirus/2c61aebbc6540e9d1b1e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.company; | |
import javax.swing.*; | |
import java.awt.*; | |
import java.awt.event.*; | |
public class GUI extends JFrame | |
implements ActionListener { | |
int gridX = 10, gridY = 10; | |
Plot[][] grid; | |
private JPanel panel; | |
public void createGUI() { | |
setSize(750, 600); | |
setDefaultCloseOperation(EXIT_ON_CLOSE); | |
Container window = getContentPane(); | |
window.setLayout(new FlowLayout()); | |
panel = new JPanel(); | |
panel.setPreferredSize(new Dimension(300, 200)); | |
panel.setBackground(Color.white); | |
window.add(panel); | |
setVisible(true); | |
} | |
public void actionPerformed(ActionEvent event) { | |
Graphics paper = panel.getGraphics(); | |
paper.drawLine(0, 0, 100, 100); | |
} | |
private void createGrid() { | |
grid = new Plot[gridX][gridY]; | |
for (int i = 0; i < grid.length; i++) { | |
for (int j = 0; j < grid[0].length; j++) { | |
grid[i][j] = new Plot(); | |
} | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.company; | |
public class Main { | |
public static void main(String[] args) { | |
GUI gui = new GUI(); | |
gui.createGUI(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.company; | |
public class Plot { | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment