Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Adding to an already created panel?  RSS feed

 
Bart Sullivan
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey gang, great site eh?
I'm trying to change the content of a panel, depending on the user's choices throughout their stay in my applet.

Is there a way to add/remove buttons, jtables, and lists in a panel after the panel has been initialized? So far I can remove but not add...
thanks for any help.
Please email me.
Bart
 
paul wheaton
Trailboss
Posts: 22255
Firefox Browser IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've removed and added stuff in applets. But I'm not using Swing, just the AWT. That shouldn't make a difference. If you are using a layout manager, you might need to force the layout manager to reshuffle stuff.
 
Bart Sullivan
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Paul Wheaton:
I've removed and added stuff in applets. But I'm not using Swing, just the AWT. That shouldn't make a difference. If you are using a layout manager, you might need to force the layout manager to reshuffle stuff.

So if I have:

Panel panel;
Button button;
later on in the code...
Panel.add(button);
Panel.remove(button);
These should both work with a Panel.repaint(); ??
 
paul wheaton
Trailboss
Posts: 22255
Firefox Browser IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
More like if you remove one button and add a different button.
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In any container, if u r removing or adding some thing, it's the Layout Manager which does all arrangement. So if u call panel.validate() method after adding or removing any component from panel then it will call layout manager to draw components again.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!