-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCardLayout1.java
More file actions
67 lines (54 loc) · 1.32 KB
/
CardLayout1.java
File metadata and controls
67 lines (54 loc) · 1.32 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
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
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class CardLayout1 extends Applet implements ActionListener
{
Checkbox cbwin98,cbwinxp,cblinux,cbmac;
Panel OScards;
CardLayout cardLO;
Button bwin,bothers;
public void init()
{
cardLO=new CardLayout();
bwin=new Button("Windows");
bothers=new Button("Others");
add(bwin);
add(bothers);
bwin.addActionListener(this);
bothers.addActionListener(this);
OScards=new Panel();
OScards.setLayout(cardLO);
//create panel for windows
Panel winpan=new Panel();
//add controls to windows panel
cbwin98=new Checkbox("Windows 98");
cbwinxp=new Checkbox("Windows XP");
winpan.add(cbwin98);
winpan.add(cbwinxp);
//create panel for others
Panel otherpan=new Panel();
//add controls to others
cblinux=new Checkbox("Linux");
cbmac=new Checkbox("Mac");
otherpan.add(cblinux);
otherpan.add(cbmac);
//add this card to card deck
OScards.add(winpan,"Windows");
OScards.add(otherpan,"Other");
//add card deck to applet windows
add(OScards);
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()=="bwin")
{
cardLO.show(OScards,"Windows");
repaint();
}
else
{
cardLO.show(OScards,"Other");
repaint();
}
}
}