DVL1 dishevelled.org

Skip to: [content] [navigation]

dishevelled.org layout 1.0-SNAPSHOT :: Downloads | Repository | Javadocs | Checkstyle | Test coverage | Changes

Summary

dishevelled.org layout provides layout manager(s) for lightweight JFC/Swing components. The only layout manager included to date is LabelFieldLayout.

LabelFieldLayout

LabelFieldLayout is a wrapper around GridBagLayout that simplifies things for the common case of two columns, one of labels and one of fields.

A simple example:

JPanel panel = new JPanel();
LabelFieldLayout l = new LabelFieldLayout();
panel.setLayout(l);

panel.add(new JLabel("Label label:"), l.labelLabel());
panel.add(new JLabel("Label field"), l.labelField());

l.nextLine();
panel.add(new JLabel("Normal label:"), l.normalLabel());
panel.add(new JTextField("Normal field"), l.normalField());

l.nextLine();
panel.add(Box.createVerticalStrut(12), l.spacing());

l.nextLine();
panel.add(new JLabel("Wide label:"), l.wideLabel());

l.nextLine();
JList list = new JList(new Object[] { "Final wide field A",
                                      "Final wide field B",
                                      "Final wide field C" });
panel.add(new JScrollPane(list), l.finalWideField());

The final component in a LabelFieldLayout stretches vertically to cover space left at the bottom of its container. It can be either an empty component, such as Box.createGlue(), a wide label, or a wide field, such as a JList in a JScrollPane, as this image demonstrates:

LabelFieldLayout example

Acknowledgements

SourceForge.net Logo