-
Notifications
You must be signed in to change notification settings - Fork 0
/
FirstWindow.java
31 lines (27 loc) · 897 Bytes
/
FirstWindow.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
//basic way to create a JFrame
import javax.swing.JFrame;
import javax.swing.JButton;
public class FirstWindow extends JFrame{
//JFrame width and height
public static final int WIDTH = 400;
public static final int HEIGHT = 200;
/**
* FirstWindow
* Basic items to create the JFrame
*/
public FirstWindow(){
super();
setSize(WIDTH, HEIGHT);
setTitle("First Normal Window Class");
setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
//a button to end the JFrame
JButton endButton = new JButton("Click to end program");
endButton.addActionListener(new EndingListener());
add(endButton);
}
//this would be in another class as the main object, calling to above method
public static void main(String[] args){
FirstWindow w = new FirstWindow();
w.setVisible(true);
}
}