Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
42 lines (36 loc) · 855 Bytes

File metadata and controls

42 lines (36 loc) · 855 Bytes
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
package chapter16;
/* J16_06.java */
/* Using Button Component */
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
public class J16_06 extends Applet implements ActionListener {
String msg = "";
public void init() {
Button y = new Button("Yes");
Button n = new Button("No");
Button c = new Button("Cancel");
add(y);
add(n);
add(c);
y.addActionListener(this);
n.addActionListener(this);
c.addActionListener(this);
}
public void actionPerformed(ActionEvent ae) {
String str = ae.getActionCommand();
if(str.equals("Yes")){
msg = "You Pressed Yes.";
}
else if(str.equals("No")){
msg = "You Pressed No.";
}
else{
msg = "You Pressed Cancel.";
}
repaint();
}
public void paint(Graphics g) {
g.drawString(msg, 10, 100);
}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.