-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMyFrame3.java
51 lines (35 loc) · 964 Bytes
/
MyFrame3.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
51
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
public class MyFrame3 extends JFrame {
private JButton exitButton = new JButton("exit");
private JButton helloButton = new JButton("hello printer");
public MyFrame3() {
super();
init();
}
private void init() {
this.getContentPane().setLayout(new FlowLayout());
this.getContentPane().add(exitButton);
this.getContentPane().add(helloButton);
this.setLocation(100,100);
this.setSize(300,200);
this.exitButton.addActionListener(
new ActionListener() {@Override
public void actionPerformed(ActionEvent e) {
dispose();
System.exit(0);
}
});
this.helloButton.addActionListener(
new ActionListener() {@Override
public void actionPerformed(ActionEvent e) {
}
});
}
public static void main(String[] args) {
MyFrame3 frame = new MyFrame3();
frame.setVisible(true);
}
}