-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathJCardLayout2.java
More file actions
43 lines (39 loc) · 1.14 KB
/
Copy pathJCardLayout2.java
File metadata and controls
43 lines (39 loc) · 1.14 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
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class JCardLayout2 extends JFrame
implements ActionListener
{
private JButton nb = new JButton("North Button");
private JButton sb = new JButton("South Button");
private JButton eb = new JButton("East Button");
private JButton wb = new JButton("West Button");
private JButton cb = new JButton("Center Button");
//private Container con = getContentPane();
CardLayout cardLayout = new CardLayout();
public JCardLayout2()
{
setLayout(cardLayout);
add("nort", nb);
add("south",sb);
add("east",eb);
add("west",wb);
add("center",cb);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
nb.addActionListener(this);
sb.addActionListener(this);
eb.addActionListener(this);
wb.addActionListener(this);
cb.addActionListener(this);
}
public void actionPerformed(ActionEvent e)
{
cardLayout.next(getContentPane());
}
public static void main(String[] args)
{
JCardLayout2 jbl = new JCardLayout2();
jbl.setSize(250,250);
jbl.setVisible(true);
}
}