This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Murach's Python Programming and have Michael Urban and Joel Murach on-line!
See this thread for details.
Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

removing and adding a panel inside actionPerformed ??  RSS feed

 
toya kin
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi guys, thanks for your attention btw
so i've come to something weird that made me think that no changes to a JPanel can be done inside the actionPerformed method

so here is how it started
Say that you want to change the whole content of a panel (i think...)
the easiest thing to do is just probably create another panel then you do whatever you do inside that new panel, when you want to change it, just remove that newly created panel then create and add another one
so i made a button that when clicked remove a panel, then add another one to the main container (the one i got from getContentPane()), but it didn't work, so then i tried adding pane.validate() and pane.repaint() (pane is the main container) and they didn't work either
and then i checked both my textbooks and found that they don't have in depth discussion on these things

so i would really appreciate if someone points me the direction to a tutorial on this or explain it to me directly
thx
 
Rachel Swailes
Ranch Hand
Posts: 434
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could also try pane.revalidate() - can you post your code so i can see if there's anything else you could try.

Cheers,
Rachel
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!