package p1;
import java.awt.CardLayout;
import java.awt.Dimension;
import java.awt.event.ActionListener;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextField;
public class InformationDemo extends JFrame {
public InformationDemo() {
super("员工信息处理");
Dimension d = this.getToolkit().getScreenSize();
this.setLocation((d.width - WIDTH) / 2, (d.height - HEIGHT) / 2);
this.setSize(WIDTH, HEIGHT);
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
this.setResizable(false);
// North1
JPanel v1 = new JPanel();
BoxLayout b1 = new BoxLayout(v1, BoxLayout.Y_AXIS);
v1.setLayout(b1);
String[] items = { "员工信息处理", "添加个人信息", "修改个人信息", "查看个人信息", "删除个人信息" };
JComboBox cbMethod = new JComboBox(items);
v1.add(cbMethod);
// North2
//先构造一个对象
CardLayout mycard1 = new CardLayout();
//构造一个子容器
JPanel v2 = new JPanel();
v2.setLayout(mycard1);
//创建10个按钮
for (int i = 1; i <= 10; i++) {
v2.add(new JButton("打印处理"));
}
mycard1.show(v2, "打印处理");
// North3
CardLayout mycard2 = new CardLayout();
JPanel v3 = new JPanel();
v3.setLayout(mycard2);
for (int i = 1; i <= 10; i++) {
v3.add(new JButton("帮助"));
}
mycard2.show(v3, "打印处理");
// North4
CardLayout mycard3 = new CardLayout();
JPanel v4 = new JPanel();
v4.setLayout(mycard3);
for (int i = 1; i <= 10; i++) {
v4.add(new JButton("退出"));
}
mycard3.show(v4, "退出");
JPanel h1 = new JPanel();
BoxLayout box1 = new BoxLayout(h1, BoxLayout.X_AXIS);
h1.setLayout(box1);
h1.add(v1);
h1.add(v2);
h1.add(v3);
h1.add(v4);
this.add(h1, "North");
setBounds(10,10,600,500);
setVisible(true);
}
public static void main(String[] args) {
new InformationDemo();
}
}