-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQuestion76.java
More file actions
38 lines (35 loc) · 1.05 KB
/
Question76.java
File metadata and controls
38 lines (35 loc) · 1.05 KB
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
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
// program to demonstrate working of CheckBox control
/* <applet code="Question76" height="200" width="300">
</applet>
*/
public class Question76 extends Applet implements ItemListener {
String msg, msgWin98, msgWinNT, msgSolaris;
Checkbox Win98, WinNT, Solaris;
public void init () {
Win98 = new Checkbox ("Windows98");
WinNT = new Checkbox ("Windows NT");
Solaris = new Checkbox ("Solaris");
add (Win98);
add (WinNT);
add (Solaris);
Win98.addItemListener (this);
WinNT.addItemListener (this);
Solaris.addItemListener (this);
}
public void itemStateChanged (ItemEvent ie) {
repaint ();
}
public void paint (Graphics g) {
msg = "Current state: ";
msgWin98 = "Windows 98: " + Win98.getState ();
msgWinNT = "Windows NT: " + WinNT.getState ();
msgSolaris = "Solaris: " + Solaris.getState ();
g.drawString (msg, 6, 100);
g.drawString (msgWin98, 6, 120);
g.drawString (msgWinNT, 6, 140);
g.drawString (msgSolaris, 6, 160);
}
}