Java Not Removing Panels?
What I want to do is when a user logs in, it changes the panel inside the current JFrame from the one used to login to the welcome screen which then the user can select features to use to or start and so on...
What I can't get the program to do is remove the panels and add new ones. I don't actually know how to do this effectively and the documentation I have found has been way to confusing and unorganized.
Thanks!
I'm only going to post the if section as I have a dialog box that pops up confirming the code can get that far in the program but wont do what I want with the panels.
Code :
if(opass.equals(dbpass)){
String result = "Entered Correct stuff.";
JOptionPane.showMessageDialog(null, result);
intro.Intro intro = new intro.Intro();
intro.remove(panel);
intro.remove(panel_1);
intro.Welcome welc = new intro.Welcome();
welc.add(panel);
welc.add(panel_1);
} else {
//INSERT CODE
}
Re: Java Not Removing Panels?
One option is to use CardLayout.
Re: Java Not Removing Panels?
Are you using revalidate() anywhere? You usually need that for the updates to appear.
Re: Java Not Removing Panels?
no, never heard about revalidate till now. lol. Did you want me to post the whole code from when the program starts and adds the "Intro" class with the Intro class? I'll do some research about revalidate and CardLayout, but if you would like to see what I've got, i don't mind. I'l just censor some of the sensitive data pertaining to the mySQL DB login.