Win a copy of Microservices Testing (Live Project) this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

Adding to an already created panel?

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Trailboss
Posts: 23459
IntelliJ IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 23459
IntelliJ IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
More like if you remove one button and add a different button.
 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic