-
Notifications
You must be signed in to change notification settings - Fork 0
/
Swing48.java
49 lines (42 loc) · 1.58 KB
/
Swing48.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
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class Swing48 extends JFrame {
public static void main(String[] args) { new Swing48(); }
JFrame frame;
JPanel panel ;
JButton button1;
Swing48(){
frame = new JFrame("Swing Program");
frame.setSize(600,500);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setLocationRelativeTo(null);
panel = new JPanel();
frame.add(panel);
button1 = new JButton("Click");
button1.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
JDialog dialog = new JDialog(frame,"JDialog1");
dialog.setSize(200,200);
dialog.setVisible(true);
JPanel panel2 =new JPanel();
dialog.add(panel2);
JButton button2 = new JButton("Click");
button2.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
JDialog dialog2 = new JDialog(dialog,"JDialog2");
dialog2.setSize(200,200);
dialog2.setVisible(true);
dialog2.add(new JLabel("This is Dialog2"));
}
});
panel2.add(button2);
}
});
panel.add(button1);
frame.setVisible(true);
}
}