Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: Java Not Removing Panels?

  1. #1
    Junior Member
    Join Date
    Aug 2011
    Location
    Wisconsin
    Posts
    6
    My Mood
    Confused
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question 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.

     
    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
    }


  2. #2
    Grand Poobah
    Join Date
    Mar 2011
    Posts
    1,545
    My Mood
    Grumpy
    Thanks
    0
    Thanked 167 Times in 158 Posts

    Default Re: Java Not Removing Panels?

    One option is to use CardLayout.
    Improving the world one idiot at a time!

  3. #3
    Forum Squatter newbie's Avatar
    Join Date
    Nov 2010
    Location
    North Wales
    Posts
    661
    My Mood
    Stressed
    Thanks
    28
    Thanked 115 Times in 106 Posts
    Blog Entries
    1

    Default Re: Java Not Removing Panels?

    Are you using revalidate() anywhere? You usually need that for the updates to appear.
    Please use [highlight=Java]//code goes here...[/highlight] tags when posting your code

  4. #4
    Junior Member
    Join Date
    Aug 2011
    Location
    Wisconsin
    Posts
    6
    My Mood
    Confused
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default 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.

Similar Threads

  1. JTabbedPane with two Panels in the same tab?
    By cadarn in forum AWT / Java Swing
    Replies: 1
    Last Post: August 3rd, 2011, 10:48 AM
  2. Help with Layouts and Panels
    By Zookey in forum What's Wrong With My Code?
    Replies: 0
    Last Post: January 29th, 2011, 06:48 PM
  3. Arraylist removing element
    By Stn in forum Loops & Control Statements
    Replies: 6
    Last Post: January 9th, 2011, 08:14 PM
  4. Removing objects from a hashSet
    By JohnTor in forum What's Wrong With My Code?
    Replies: 1
    Last Post: December 4th, 2010, 03:03 PM
  5. Adding panels to a central panel.
    By Johannes in forum AWT / Java Swing
    Replies: 3
    Last Post: July 4th, 2010, 05:31 PM