Problem using FormLayout in Swing
Posted
by Dimitri
on Stack Overflow
See other posts from Stack Overflow
or by Dimitri
Published on 2010-05-25T15:37:07Z
Indexed on
2010/05/25
15:51 UTC
Read the original article
Hit count: 175
Hi I am using the FormLayout
. I just discovered it and it's powerful layout manager.
I would like to layout 4 components (outlined, properties, tgraph, library) in 3 columns.
I want to layout my library component on top of the outlined component in one column, the graph and the properties component in one column.
But it doesn't work. Maybe I miss something. Here is my code :
private void layoutComponent() {
JPanel panel = new JPanel();
FormLayout layout = new FormLayout(
"right:p,10dlu,300dlu,left:max(50dlu;p)",
"top:pref,center:p,p");
layout.setRowGroups(new int[][]{{1,3}});
PanelBuilder builder = new PanelBuilder(layout,panel);
builder.setDefaultDialogBorder();
CellConstraints constraints = new CellConstraints();
builder.add(library, constraints.xy(1, 1));
builder.add(outline,constraints.xy(1, 3));
builder.add(tgraph,constraints.xy(3, 1));
builder.add(properties,constraints.xy(4, 1));
getContentPane().add(panel);r code here
}
Can someone help plz. Thx :)
© Stack Overflow or respective owner