aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Need to load the panel with fresh content Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Need to load the panel with fresh content" Watch "Need to load the panel with fresh content" New topic
Author

Need to load the panel with fresh content

Seetamraj Sriharsha
Greenhorn

Joined: Nov 09, 2009
Posts: 20
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

Joined: Oct 27, 2005
Posts: 19718
    
  20

Did you revalidate() and repaint() your user interface after changing removing and re-adding the components?


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Seetamraj Sriharsha
Greenhorn

Joined: Nov 09, 2009
Posts: 20
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

Joined: Nov 09, 2009
Posts: 20
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Need to load the panel with fresh content