-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathdialog_modal.java
executable file
·174 lines (137 loc) · 4.09 KB
/
dialog_modal.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
import java.io.*;
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import java.awt.image.*;
class dialogMain extends Dialog implements java.awt.event.WindowListener,java.awt.event.MouseListener{
public dialogMain(Frame frame) {
super(frame,"this is modal dialog",true);
// TODO Auto-generated constructor stub
this.setSize(100,100);
this.addWindowListener(this);
Button OK_button=new Button("OK");
OK_button.addMouseListener(this);
this.add(OK_button);
this.setVisible(true);
}
public void windowActivated(WindowEvent arg0) {
// TODO Auto-generated method stub
}
public void windowClosed(WindowEvent arg0) {
// TODO Auto-generated method stub
}
public void windowClosing(WindowEvent arg0) {
// TODO Auto-generated method stub
this.dispose();
System.out.println("close window");
}
public void windowDeactivated(WindowEvent arg0) {
// TODO Auto-generated method stub
}
public void windowDeiconified(WindowEvent arg0) {
// TODO Auto-generated method stub
}
public void windowIconified(WindowEvent arg0) {
// TODO Auto-generated method stub
}
public void windowOpened(WindowEvent arg0) {
// TODO Auto-generated method stub
}
public void mouseClicked(MouseEvent arg0) {
// TODO Auto-generated method stub
System.out.println("You click to button OK");
this.dispose();
}
public void mouseEntered(MouseEvent arg0) {
// TODO Auto-generated method stub
}
public void mouseExited(MouseEvent arg0) {
// TODO Auto-generated method stub
}
public void mousePressed(MouseEvent arg0) {
// TODO Auto-generated method stub
}
public void mouseReleased(MouseEvent arg0) {
// TODO Auto-generated method stub
}
}
class frameMain extends Frame implements java.awt.event.WindowListener,java.awt.event.MouseListener,java.awt.event.ActionListener{
Button my_button;
Panel panel;
frameMain(Dimension d){
super("hello frame");
panel=new Panel();
// create button
my_button=new Button("my_button");
// add Mouse Listener to button's
my_button.addMouseListener(this);
this.add(my_button);
this.setSize(d);
this.addWindowListener(this);
//this.setLayout(new FlowLayout(FlowLayout.LEFT));
}
frameMain(){
this(new Dimension(100,200));
}
public void windowActivated(WindowEvent arg0) {
// TODO Auto-generated method stub
}
public void windowClosed(WindowEvent arg0) {
// TODO Auto-generated method stub
}
public void windowClosing(WindowEvent arg0) {
// TODO Auto-generated method stub
this.dispose();
}
public void windowDeactivated(WindowEvent arg0) {
// TODO Auto-generated method stub
}
public void windowDeiconified(WindowEvent arg0) {
// TODO Auto-generated method stub
}
public void windowIconified(WindowEvent arg0) {
// TODO Auto-generated method stub
}
public void windowOpened(WindowEvent arg0) {
// TODO Auto-generated method stub
}
public void mouseClicked(MouseEvent arg0) {
// TODO Auto-generated method stub
System.out.println(arg0.getComponent().getName());
if(arg0.getComponent() instanceof Button){
System.out.println(((Button)(arg0.getComponent())).getLabel());
if(((Button)(arg0.getComponent())).getLabel().equalsIgnoreCase("my_button")){
dialogMain dialog1=new dialogMain(this);
}
}
}
public void mouseEntered(MouseEvent arg0) {
// TODO Auto-generated method stub
}
public void mouseExited(MouseEvent arg0) {
// TODO Auto-generated method stub
}
public void mousePressed(MouseEvent arg0) {
// TODO Auto-generated method stub
}
public void mouseReleased(MouseEvent arg0) {
// TODO Auto-generated method stub
}
public void actionPerformed(ActionEvent arg0) {
// TODO Auto-generated method stub
System.out.println(arg0.getSource());
}
}
public class main_class extends Applet{
Frame fmMain;
public void init(){
fmMain=new frameMain();
fmMain.setVisible(true);
}
public void destroy(){
}
public void start(){
}
public void stop(){
}
}