-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDemoDialog.java
More file actions
41 lines (37 loc) · 894 Bytes
/
DemoDialog.java
File metadata and controls
41 lines (37 loc) · 894 Bytes
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
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
//<applet code="DemoDialog.class" height=400 width=400></applet>
public class DemoDialog extends JApplet implements ActionListener
{
JPanel pnl;
JButton b1;
public void init()
{
pnl = new JPanel();
getContentPane().add(pnl);
b1 = new JButton("Click Me");
pnl.add(b1);
b1.addActionListener(this);
}
public void actionPerformed(ActionEvent e)
{
if (e.getSource() == b1)
{
int result;
result = JOptionPane.showConfirmDialog(this, "Continue???");
switch (result)
{
case JOptionPane.YES_OPTION:
showStatus("yes Button was Pressed...");
break;
case JOptionPane.NO_OPTION:
showStatus("No Button was Pressed...");
break;
case JOptionPane.CANCEL_OPTION:
showStatus("Cancel Button was Pressed...");
break;
}
}
}
}