Changing the alignment of FormLayout at run time

Can I use JGoodies FormLayout to change the alignment of a component after installing it?

eg,

CellConstraints cc = new CellCosntraints(); panel.add(component,cc.xy(1,1,CellConstraints.DEFAULT,CellConstraints.FILL)); 

If I want to change component to have a DEFAULT string constraint instead of FILL, is there a way to change it now that it has been installed without removing and re-adding the component?

+4
source share
2 answers

It looks like you can:

 FormLayout l = new FormLayout(); ... l.setContraints(component, newconstraints); 

then probably do revalidate() in the container for the update.

+5
source

there are two ways (@Jim +1 for the right direction)

1) fills the available size inside the container without resizing for the container

 revalidate() //covered validate() repaint() // required in some cases for JLabel, JTextComponents, JScrollPane ... 

2) fills the available size inside the container with the size for the container

 pack(); 

this code can help you

0
source

Source: https://habr.com/ru/post/1399838/


All Articles