-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcardlayout.java
More file actions
53 lines (41 loc) · 1.29 KB
/
cardlayout.java
File metadata and controls
53 lines (41 loc) · 1.29 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
import java.awt.Button;
import java.awt.CardLayout;
import java.awt.Color;
import java.awt.Frame;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowEvent;
public class cardlayout extends Frame implements ActionListener {
Button b1, b2, b3;
CardLayout card;
public cardlayout(){
this.setVisible(true);
this.setSize(500,500);
this.addWindowListener(new windowadapter(){
public void windowClosing(WindowEvent e){
System.exit(0);
}
});
card= new CardLayout();
this.setLayout(card);
b1= new Button("RED");
b2= new Button("GREEN");
b3= new Button("YELLOW");
b1.setBackground(Color.RED);
b2.setBackground(Color.GREEN);
b2.setBackground(Color.YELLOW);
b1.addActionListener(this);
b2.addActionListener(this);
b3.addActionListener(this);
this.add(b1);
this.add(b2);
this.add(b3);
}
@Override
public void actionPerformed(ActionEvent e) {
card.next(this);
}
public static void main(String[] args) {
cardlayout c= new cardlayout();
}
}