问题
I'm building an application using Netbeans where I have to switch from one JPanel to another when a specific JMenu is clicked.
I have tried to use the following code but it won't work.
MainPane is the main panel, NewpatientPane is the panel to switch to while card2 is the card name for the NewpatientPane.
Any help will be appreciated.
public void pharmacyMenuActionPerformed(java.awt.event.ActionEvent evt){
CardLayout card = (CardLayout)MainPane.getLayout();
card.show(Mainpane, "card2");
NewpatientPane.setVisible(true);
}
来源:https://stackoverflow.com/questions/62969737/how-to-switch-jpanel-cards-when-a-jmenu-is-clicked