forked from ranjansharma255/Java_Programs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCheckboxGroupDemo.java
More file actions
34 lines (34 loc) · 874 Bytes
/
Copy pathCheckboxGroupDemo.java
File metadata and controls
34 lines (34 loc) · 874 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
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
/*<applet code = CheckboxGroupDemo width = 300 height = 300 > </applet>*/
public class CheckboxGroupDemo extends Applet implements ItemListener
{
Checkbox a,b,c;
public void init()
{
CheckboxGroup g = new CheckboxGroup();
a = new Checkbox("Red",g,false);
b = new Checkbox("Pink",g,false);
c = new Checkbox("Green",g,false);
add(a);
add(b);
add(c);
a.addItemListener(this);
b.addItemListener(this);
c.addItemListener(this);
}
public void itemStateChanged(ItemEvent e)
{
if(a.getState() == true)
setBackground(Color.red);
else if(b.getState() == true)
setBackground(Color.pink);
else if(c.getState() == true)
setBackground(Color.green);
}
public void paint(Graphics g)
{
showStatus("Radio Button Selected color is displayed");
}
}