-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNotHelloWorld.java
50 lines (43 loc) · 1.18 KB
/
NotHelloWorld.java
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
45
46
47
48
49
50
package notHelloWorld;
import javax.swing.*;
import java.awt.*;
/**
* @author Cay Horstmann
* @version 1.33 2015-05-12
*/
public class NotHelloWorld {
public static void main(String[] args) {
EventQueue.invokeLater(() -> {
JFrame frame = new NotHelloWorldFrame();
frame.setTitle("NotHelloWorld");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
});
}
}
/**
* A frame that displays a message.
*/
class NotHelloWorldFrame extends JFrame {
public NotHelloWorldFrame() {
add(new NotHelloWorldComponent());
pack();
}
}
/**
* A component that displays a message.
*/
class NotHelloWorldComponent extends JComponent {
public static final int MESSAGE_X = 75;
public static final int MESSAGE_Y = 100;
public static final int DEFAULT_WIDTH = 300;
public static final int DEFAULT_HEIGHT = 300;
@Override
protected void paintComponent(Graphics g) {
g.drawString("Not a Hello, World program", MESSAGE_X, MESSAGE_Y);
}
@Override
public Dimension getPreferredSize() {
return new Dimension(DEFAULT_WIDTH, DEFAULT_HEIGHT);
}
}