• Post Reply Bookmark Topic Watch Topic
  • New Topic

Container (JPanel) refresh problem  RSS feed

 
Laurent Sate
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
In fact i have a panel (mainPanel) with a button OK, a another panel which display a specific MyJTable and combo box.
In fact, when I clic OK Button, i want to charge my MyJTable with data depends on comboBox.
First, i display a empty white panel and when i clic Ok i want to display my MyJTable.

I have a refresh problem, i try mainPanel.remove(emptyPanel) and thus mainPanel.add(myJTable), the remove works but the add no

Thanks for yu help!!
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
instead of calling repaint(), you need to call revalidate()... repaint tells the component to repaint itself, revalidate tells the component it needs to run it's layout manager again and repaint... If you are adding or removing components, then the component needs to be layed out again.

-Nate
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!