Reputation: 11
I have a two JPanel
s: a1
and a2
. a11
is sub panel of a1
. I want move a11
to a2
.
How to do this?
Upvotes: 1
Views: 629
Reputation: 7212
Try this:
a2.add(a11); // move a11 from a1 to a2
a2.revalidate(); // apply changes in a2 layout
a1.revalidate(); // apply changes in a1 layout
a2.repaint(); // repaint a2 you to be able to see the changes
a1.repaint(); // repaint a1 you to be able to see the changes
Upvotes: 4
Reputation: 2762
you can do that by first remove a11 from a1 and then adding it to a2.
as follows,
a1.remove(a11);
a2.add(a11);
a2.repaint();
Upvotes: 3