定义好一个jpanel的卡片布局,也将卡片添加到jpanel里面,怎么在监听器里面调用相应的卡片。
jpanelSorthright.setBackground(Color.ORANGE); //jpanelSorthright相关设置
jpanelSorthright.setPreferredSize(new Dimension(600,400));
jpanelSorthright.setLayout(new CardLayout());
cardinsert card_insert = new cardinsert(); //生成的是jpanel,自定义jpanel
carddelete card_delete = new carddelete();
cardupdate1 card_update = new cardupdate1();
cardselect1 card_select = new cardselect1();
jpanelSorthright.add(card_insert.jpanel_one(),"insert");
jpanelSorthright.add(card_delete.jPanel_two(),"delete");
jpanelSorthright.add(card_update.jPanel_three(),"update");
jpanelSorthright.add(card_select.jPanel_four(),"selete");
button_insert.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
}
});
button_delete.addActionListener();
button_update.addActionListener();
button_select.addActionListener();