This week's book giveaway is in the Performance forum.
We're giving away four copies of The Java Performance Companion and have Charlie Hunt, Monica Beckwith, Poonam Parhar, & Bengt Rutisson on-line!
See this thread for details.
Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Need to load the panel with fresh content

 
Seetamraj Sriharsha
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm working with 4X4 grid of buttons (16). I need to change all the buttons when I click a the "New game". I tried removeAll() of panel and than tried to call the same class to create 16 buttons again for the panel. But it didn't work.

Following is the similar program I'm stuck with. Please help me with the code.

Main.java


MyFrame.java


FirstPanel.java


SecondPanel.java


 
Rob Spoor
Sheriff
Pie
Posts: 20546
57
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you revalidate() and repaint() your user interface after changing removing and re-adding the components?
 
Seetamraj Sriharsha
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob Prime wrote:Did you revalidate() and repaint() your user interface after changing removing and re-adding the components?


Ya i tried to repaint()... but where should I revalidate(). What does component validation mean ?


 
Seetamraj Sriharsha
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I got it Rob Prime I was actually creating new object for SecondPanel. Now I just created another method which adds my new component and called it directly from my MYFrame class.


In MyFrame.java



in Second Panel.java
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic