• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to use menus?

 
Ron Aronica
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am having, what must be a simple problem. When I place a JTable, or any other object, on the content pane when starting the program all is well, but when I place it on the pane in response to a menu item action, the table does not display. What am I doing wrong, or more likely, what do I not know?
Thanks for your help.

(The following is just the relevant code--I hope.)
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
call contentPane.validate(); right before contentPane.reapaint();

validate() tells the container to call it's layout manager again to lay out it's components. (Which needs to be done whenever you do a dynamic add() or remove() like this...)
 
Ron Aronica
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks; it worked like a champ!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!