com.jgoodies.forms.factories
Class DefaultComponentFactory

java.lang.Object
  extended by com.jgoodies.forms.factories.DefaultComponentFactory
All Implemented Interfaces:
ComponentFactory

public class DefaultComponentFactory
extends Object
implements ComponentFactory

A singleton implementation of the ComponentFactory interfac that creates UI components as required by th PanelBuilder.

#createLabel(String) an #createTitle(String) can contain an optional mnemonic marker The mnemonic and mnemonic index are indicated by a single ampersan (&). For example "&Save" or "Save &as". To use the ampersand itsel duplicate it, for example "Look&&Feel".

Version:
$Revision: 1.21 $
Author:
Karsten Lentzsch

Constructor Summary
DefaultComponentFactory()
           
 
Method Summary
 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 use 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 mnemoni that is intended to label a read-only component.
 JComponent createSeparator(JLabel label)
          Creates and returns a labeled separator.
 JComponent createSeparator(String textWithMnemonic)
          Creates and returns a labeled separator with the label in the left-han side.
 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 colo and font of a TitledBorder.
static DefaultComponentFactory getInstance()
          Returns the sole instance of this factory class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultComponentFactory

public DefaultComponentFactory()
Method Detail

getInstance

public static DefaultComponentFactory getInstance()
Returns the sole instance of this factory class.

Returns:
the sole instance of this factory class

createLabel

public JLabel createLabel(String textWithMnemonic)
Creates and returns a label with an optional mnemonic.

Specified by:
createLabel in interface ComponentFactory
Parameters:
textWithMnemonic - the label's text may contain an ampersand (&) to mark a mnemonic
Returns:
an label with optional mnemonic

createReadOnlyLabel

public JLabel createReadOnlyLabel(String textWithMnemonic)
Creates and returns a label with an optional mnemoni that is intended to label a read-only component.

Specified by:
createReadOnlyLabel in interface ComponentFactory
Parameters:
textWithMnemonic - the label's text may contain an ampersand (&) to mark a mnemonic
Returns:
an label with optional mnemonic intended for read-onl components
Since:
1.3

createButton

public JButton createButton(Action action)
Creates and returns a button that is bound to the given Action Useful to return customized buttons, for example, the JGoodie JGButton is bound to some custom Action properties.

JButton.

Specified by:
createButton in interface ComponentFactory
Parameters:
action - provides [bound] visual properties for the button
Returns:
the created button
Since:
1.4

createTitle

public JLabel createTitle(String textWithMnemonic)
Creates and returns a title label that uses the foreground colo and font of a TitledBorder.

Specified by:
createTitle in interface ComponentFactory
Parameters:
textWithMnemonic - the label's text may contain an ampersand (&) to mark a mnemonic
Returns:
an emphasized title label

createHeaderLabel

public JLabel createHeaderLabel(String markedText)
Description copied from interface: ComponentFactory
Creates and returns a label intended for pane headers that use 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 describe by the MS User Experience Guide.

markedText is "&Charge Codes", the tex will be set to "Charge Codes", the mnemonic is 'C', and th mnemonic index is 0.

ComponentFactory.createTitle(String).

Specified by:
createHeaderLabel in interface ComponentFactory
Parameters:
markedText - the label text with optional mnemonic marker
Returns:
a label intended for pane headers

createSeparator

public JComponent createSeparator(String textWithMnemonic)
Creates and returns a labeled separator with the label in the left-han side. Useful to separate paragraphs in a panel; often a better choic than a TitledBorder.

Parameters:
textWithMnemonic - the label's text may contain an ampersand (&) to mark a mnemonic
Returns:
a title label with separator on the side

createSeparator

public JComponent createSeparator(String textWithMnemonic,
                                  int alignment)
Creates and returns a labeled separator. Useful to separat paragraphs in a panel, which is often a better choice than TitledBorder.

Specified by:
createSeparator in interface ComponentFactory
Parameters:
textWithMnemonic - the label's text may contain an ampersand (&) to mark a mnemonic
alignment - text alignment, one of SwingConstants.LEFT SwingConstants.CENTER, SwingConstants.RIGHT
Returns:
a separator with title label

createSeparator

public JComponent createSeparator(JLabel label)
Creates and returns a labeled separator. Useful to separat paragraphs in a panel, which is often a better choice than TitledBorder.

SwingConstants.LEFT SwingConstants.CENTER SwingConstants.RIGHT.

Parameters:
label - the title label component
Returns:
a separator with title label
Throws:
NullPointerException - if the label is null
IllegalArgumentException - if the label's horizontal alignmen is not one of: SwingConstants.LEFT SwingConstants.CENTER SwingConstants.RIGHT.
Since:
1.0.6


Copyright © 2002-2013 JGoodies Software GmbH. All Rights Reserved.