Interface ComponentFactory
- All Known Implementing Classes:
DefaultComponentFactory
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
"&Saveinvalid input: '"', or "Save &asinvalid input: '"'.
To use the ampersand itself duplicate it, for example
"Look&&Feelinvalid input: '"'.
- Version:
- $Revision: 1.10 $
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptioncreateButton
(Action action) Creates and returns a button that is bound to the given Action.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.createLabel
(String textWithMnemonic) Creates and returns a label with an optional mnemonic.createReadOnlyLabel
(String textWithMnemonic) Creates and returns a label with an optional mnemonic that is intended to label a read-only component.createSeparator
(String textWithMnemonic, int alignment) Creates and returns a labeled separator.createTitle
(String textWithMnemonic) Creates and returns a title label that uses the foreground color and font of aTitledBorder
.
-
Method Details
-
createButton
Creates and returns a button that is bound to the given Action. Useful to return customized buttons, for example, the JGoodiesJGButton
is bound to some custom Action properties.- Parameters:
action
- provides [bound] visual properties for the button- Returns:
- the created button
- Since:
- 1.4
-
createLabel
Creates and returns a label with an optional mnemonic.createLabel("Name"); // No mnemonic createLabel("Ninvalid input: '&ame'"); // Mnemonic is 'a' createLabel("Save invalid input: '&as'"); // Mnemonic is the second 'a' createLabel("Lookinvalid input: '&'invalid input: '&Feel'"); // No mnemonic, text is Lookinvalid input: '&Feel'
- Parameters:
textWithMnemonic
- the label's text - may contain an ampersand (&) to mark a mnemonic- Returns:
- an label with optional mnemonic
-
createReadOnlyLabel
Creates and returns a label with an optional mnemonic that is intended to label a read-only component.createReadOnlyLabel("Name"); // No mnemonic createReadOnlyLabel("Ninvalid input: '&ame'"); // Mnemonic is 'a' createReadOnlyLabel("Save invalid input: '&as'"); // Mnemonic is the second 'a' createReadOnlyLabel("Lookinvalid input: '&'invalid input: '&Feel'"); // No mnemonic, text is Lookinvalid input: '&Feel'
- Parameters:
textWithMnemonic
- the label's text - may contain an ampersand (&) to mark a mnemonic- Returns:
- an label with optional mnemonic intended for read-only components
- Since:
- 1.3
-
createTitle
Creates and returns a title label that uses the foreground color and font of aTitledBorder
.createTitle("Name"); // No mnemonic createTitle("Ninvalid input: '&ame'"); // Mnemonic is 'a' createTitle("Save invalid input: '&as'"); // Mnemonic is the second 'a' createTitle("Lookinvalid input: '&'invalid input: '&Feel'"); // No mnemonic, text is Lookinvalid input: '&Feel'
- Parameters:
textWithMnemonic
- the label's text - may contain an ampersand (&) to mark a mnemonic- Returns:
- an emphasized title label
-
createHeaderLabel
Creates and returns a label intended for pane headers that uses a larger font than the control font and a special foreground color. For example, on the Windows platform this method may use the font, size, and color of the TaskDialog main instruction as described by the MS User Experience Guide.If the label text is marked with the mnemonic marker 'invalid input: '&'', the mnemonic and mnemonic index will be configured. For example if
markedText
is "invalid input: '&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)
.- Parameters:
markedText
- the label text with optional mnemonic marker- Returns:
- a label intended for pane headers
- Since:
- 1.6
-
createSeparator
Creates and returns a labeled separator. Useful to separate paragraphs in a panel, which is often a better choice than aTitledBorder
.final int LEFT = SwingConstants.LEFT; createSeparator("Name", LEFT); // No mnemonic createSeparator("Ninvalid input: '&ame'", LEFT); // Mnemonic is 'a' createSeparator("Save invalid input: '&as'", LEFT); // Mnemonic is the second 'a' createSeparator("Lookinvalid input: '&'invalid input: '&Feel'", LEFT); // No mnemonic, text is Lookinvalid input: '&Feel'
- Parameters:
textWithMnemonic
- the label's text - may contain an ampersand (&) to mark a mnemonicalignment
- text alignment, one ofSwingConstants.LEFT
,SwingConstants.CENTER
,SwingConstants.RIGHT
- Returns:
- a title label with separator on the side
-