Change FormLayout alignment at runtime
-
07-12-2019 - |
Question
Is there a way using JGoodies FormLayout to change the alignment of a component once it has been set?
for example,
CellConstraints cc = new CellCosntraints();
panel.add(component,cc.xy(1,1,CellConstraints.DEFAULT,CellConstraints.FILL));
If I want to change component
to be have a row constraint of DEFAULT instead of FILL, is there a way to change it now that it has been set without removing and re-adding the component?
Solution
It looks like you can:
FormLayout l = new FormLayout();
...
l.setContraints(component, newconstraints);
then probably do a revalidate()
on the container to update things.
OTHER TIPS
there are two ways (@Jim +1 for correct direction)
1) fills available Dimension inside container without resize for container
revalidate() //covered validate()
repaint() // required in some cases for JLabel, JTextComponents, JScrollPane ...
2) fills available Dimension inside container with resize for container
pack();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow