public interface ComponentFactory
FormBuilder, ListViewBuilder, and other builders.
The String arguments passed to the methods #createLabel(String),
#createTitle(String), and
#createSeparator(String, int) can contain an optional
mnemonic marker. The mnemonic and mnemonic index are indicated
by a single ampersand (&). For example
"&Save", or "Save &as".
To use the ampersand itself duplicate it, for example
"Look&&Feel".
DefaultComponentFactory,
FormBuilder| Modifier and Type | Method and Description |
|---|---|
JButton |
createButton(Action action)
Creates and returns a button that is bound to the given Action.
|
JLabel |
createHeaderLabel(String markedText)
Creates and returns a label intended for pane headers that uses
a larger font than the control font and a special foreground color.
|
JLabel |
createLabel(String textWithMnemonic)
Creates and returns a label with an optional mnemonic.
|
JLabel |
createReadOnlyLabel(String textWithMnemonic)
Creates and returns a label with an optional mnemonic
that is intended to label a read-only component.
|
JComponent |
createSeparator(String textWithMnemonic,
int alignment)
Creates and returns a labeled separator.
|
JLabel |
createTitle(String textWithMnemonic)
Creates and returns a title label that uses the foreground color
and font of a
TitledBorder. |
JButton createButton(Action action)
JGButton is bound to some custom Action properties.action - provides [bound] visual properties for the buttonJLabel createLabel(String textWithMnemonic)
createLabel("Name"); // No mnemonic
createLabel("N&ame"); // Mnemonic is 'a'
createLabel("Save &as"); // Mnemonic is the second 'a'
createLabel("Look&&Feel"); // No mnemonic, text is Look&Feel
textWithMnemonic - the label's text -
may contain an ampersand (&) to mark a mnemonicJLabel createReadOnlyLabel(String textWithMnemonic)
createReadOnlyLabel("Name"); // No mnemonic
createReadOnlyLabel("N&ame"); // Mnemonic is 'a'
createReadOnlyLabel("Save &as"); // Mnemonic is the second 'a'
createReadOnlyLabel("Look&&Feel"); // No mnemonic, text is Look&Feel
textWithMnemonic - the label's text -
may contain an ampersand (&) to mark a mnemonicJLabel createTitle(String textWithMnemonic)
TitledBorder.
createTitle("Name"); // No mnemonic
createTitle("N&ame"); // Mnemonic is 'a'
createTitle("Save &as"); // Mnemonic is the second 'a'
createTitle("Look&&Feel"); // No mnemonic, text is Look&Feel
textWithMnemonic - the label's text -
may contain an ampersand (&) to mark a mnemonicJLabel createHeaderLabel(String markedText)
If the label text is marked with the mnemonic marker '&',
the mnemonic and mnemonic index will be configured.
For example if markedText is "&Charge Codes", the text
will be set to "Charge Codes", the mnemonic is 'C', and the
mnemonic index is 0.
A simple implementation may just delegate to
createTitle(String).
markedText - the label text with optional mnemonic markerJComponent createSeparator(String textWithMnemonic, int alignment)
TitledBorder.
final int LEFT = SwingConstants.LEFT;
createSeparator("Name", LEFT); // No mnemonic
createSeparator("N&ame", LEFT); // Mnemonic is 'a'
createSeparator("Save &as", LEFT); // Mnemonic is the second 'a'
createSeparator("Look&&Feel", LEFT); // No mnemonic, text is Look&Feel
textWithMnemonic - the label's text -
may contain an ampersand (&) to mark a mnemonicalignment - text alignment, one of SwingConstants.LEFT,
SwingConstants.CENTER, SwingConstants.RIGHTCopyright © 2002-2015 JGoodies Software GmbH. All Rights Reserved.