Reputation: 187
I got two JPanels in a GridBagLayout, a canvas and a toolbox, and if the user clicks over the toolbox panel I want it to change size (essentially opening it). Is there a (smarter) way to modify the weight of the toolbox constraint without having to remove all the components from the parent panel and re-adding the canvas and toolbox but with modified constraints?
Upvotes: 1
Views: 523
Reputation: 8348
You can change the constraints of a Component
already contained in a Container
with a GridBagLayout
by calling
GridBagLayout
with the appropriate GridBagConstraint
objectrevalidate
and repaint
on the Container
Upvotes: 5