Win a copy of Head First Agile this week in the Agile forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

how do I remove a JPanel from a contentPane?  RSS feed

 
Matt Wilcko
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am working on a program and when it starts a splash screen appears. After 5 seconds I would like it to disappear. I have no problem making the splash screen appear but I am stumped with removing it. Here is how I have it setup:
Under the a class FrameSet(extends JFrame), I have:
Container contentPane = getContentPane();
WorkAreaPanel workArea = new WorkAreaPanel(); //extends JPanel, displays jpeg using g2d.Drawimage
contentPane.add(workArea);
this works fine.. I assume to remove it I would use:
contentPane.remove(workArea); OR
contentPane.removeAll;
no luck, simply having either of these last lines in there causes the workArea(which is my splash screen) to never appear.
help!
Are there any good tutorials on this?
Thanks!
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're going to have to have a thread to control this... something like the example below :

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!