Class FormPanel
java.lang.Object
be.imgn.swing.ui.FormPanel
Lays out a form in two columns, with
GridBagLayout, in the order its methods are called: rows of a label and
its field, wide components across both columns, and section titles. Every cell has an inset of 4 pixels on each side,
and the panel an empty border of 4 pixels. The wide components share the extra height; without one, the rows stay at
the top of the panel.
The labels are typically Exposed fields of the view, so their texts and mnemonics come from its resources,
as for any component.
Every method is called on the EDT. build() may be called once: any call afterwards throws
IllegalStateException.
-
Method Summary
Modifier and TypeMethodDescriptionbuild()Returns the panel.static FormPanelcreate()Returns a new, empty form panel.row(JLabel label, JComponent field) Adds a label and its field: the label at the line end of the first column, the field filling the width of the second.Adds a title across both columns: the label, followed by aJSeparatorthat fills the rest of the row, 4 pixels after it, on the label's trailing side whatever the component orientation.wide(JComponent component) Adds a component across both columns, filling the row's width and sharing the extra height with the other wide components, as a nested panel or a text area needs.
-
Method Details
-
create
-
row
Adds a label and its field: the label at the line end of the first column, the field filling the width of the second. Callslabel.setLabelFor(field), so the label's mnemonic focuses the field.- Parameters:
label- the labelfield- the field- Returns:
- this form panel
- Throws:
IllegalStateException- if the panel was built
-
wide
Adds a component across both columns, filling the row's width and sharing the extra height with the other wide components, as a nested panel or a text area needs.- Parameters:
component- the component- Returns:
- this form panel
- Throws:
IllegalStateException- if the panel was built
-
section
Adds a title across both columns: the label, followed by aJSeparatorthat fills the rest of the row, 4 pixels after it, on the label's trailing side whatever the component orientation.- Parameters:
title- the title- Returns:
- this form panel
- Throws:
IllegalStateException- if the panel was built
-
build
Returns the panel. It may be called once: any call on this form panel afterwards throwsIllegalStateException.- Returns:
- the panel
- Throws:
IllegalStateException- if the panel was built
-