-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCanvas.java
More file actions
44 lines (38 loc) · 972 Bytes
/
Copy pathCanvas.java
File metadata and controls
44 lines (38 loc) · 972 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package house;
/**
* Provides a panel which can be used for drawing.
*
* @author Björn Gottfried
* @version 1.0
*/
import javax.swing.JFrame;
import javax.swing.JPanel;
import java.awt.Graphics;
import java.awt.BorderLayout;
import java.awt.Dimension;
@SuppressWarnings("serial")
public class Canvas extends JFrame {
public static Graphics PEN;
private Application myApp;
private class CanvasPanel extends JPanel {
@Override
protected void paintComponent(Graphics pen) {
super.paintComponent(pen);
PEN = pen;
myApp.draw();
}
}
public Canvas(String title) {
super(title);
setLayout(new BorderLayout());
myApp = new Application();
add(new CanvasPanel(), BorderLayout.CENTER);
Dimension screenSize = getToolkit().getScreenSize();
setBounds(0, 0, screenSize.width, screenSize.height);
setVisible(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public static void main(String[] args) {
new Canvas("Some art");
}
}