I'm trying to make the JPanels swap from one to another. Sounds simple, but I'm struggling due to having my panels all in different classes.
I have 4 classes: - GUI (Main class) - BankingAppMainFrame (JFrame class) - BankingAppStartPanel (JPanel class)
Here is my relevant JFrame code:
//This is the only way i didn't get errors xD
public void panelSwap(JFrame z, JPanel x, JPanel y) {
z.remove(x);
z.add(y);
}
Here is my relevant BankingAppStartPanel code:
LoginButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent event) {
//I thought I'd need to instance all my classes
BankingAppMainFrame mainFrame = new BankingAppMainFrame();
BankingAppStartPanel startPanel = new BankingAppStartPanel();
BankingAppLoginPanel loginPanel = new BankingAppLoginPanel();
//This is calling the panelSwap method from the main Class
mainFrame.panelSwap(mainFrame, startPanel, loginPanel);
}
});
The BankingAppLoginPanel is just a blank panel at the moment until I can get this to work.
What I'm trying to do is remove the current Panel (In this case "BankingAppStartPanel" and replace it with the "BankingAppLoginPanel".