Forums Register Login

Adding to an already created panel?

+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
 

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(); ??
+Pie Number of slices to send: Send
More like if you remove one button and add a different button.
+Pie Number of slices to send: Send
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.
Hang a left on main. Then read this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 782 times.
Similar Threads
JSplitPane
Repaint my swing app
repaint problem
how to add background image to applet
JSplitPane, JTable
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 09:40:43.