last week I have started using Swing Designer and so far I am quite satisfied. To evaluate the Swing Designer I have tried to open Swing GUIs currently in use in my company which works fine in most cases. Some applications use the JGoodies PanelBuilder to create panels with FormLayout (DefaultFormBuilder). Unfortunately Swing Designer seems to have problems dealing with JPanel objects created by DefaultFormBuilder or other builders like ButtonBarBuilder.
When I work with a JPanel as root container and would like to use panels created by PanelBuilder Swing Designer either does not show them in the preview at all or the preview is not correct. But if I use this root JPanel as a custom component and add it to a JFrame then the preview works just fine. Am I doing something wrong or is it a bug in the Swing Designer?
I am using JGoodies forms 1.2.0
Here is an example of such JPanel:
- Code: Select all
public PanelBuilderTest()
{
initGUI();
}
private void initGUI()
{
setLayout(new FormLayout(new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC,
FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC,
FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC,
FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC,
FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), }, new RowSpec[] {
FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC,
FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC,
FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
FormFactory.RELATED_GAP_ROWSPEC, RowSpec.decode("default:grow"), }));
add(this.buildCenterPanel(), "14, 14, fill, fill");
}
private JPanel buildCenterPanel()
{
DefaultFormBuilder builder = new DefaultFormBuilder(new FormLayout("5dlu, pref, 7dlu, pref, 5dlu:grow", ""));
// builder.setRowGroupingEnabled(true);
builder.setLeadingColumnOffset(1);
builder.appendSeparator("Sep");
JLabel label = new JLabel("lbl");
builder.append(label);
JTextField text = new JTextField();
text.setName("name");
text.setHorizontalAlignment(SwingConstants.RIGHT);
builder.append(text);
builder.nextLine();
return builder.getPanel();
}