com.jgoodies.forms.factories
Class DefaultComponentFactory

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

public class DefaultComponentFactory
extends java.lang.Object
implements ComponentFactory

A singleton implementaton of the ComponentFactory interface that creates UI components as required by the PanelBuilder.

Version:
$Revision: 1.1 $
Author:
Karsten Lentzsch

Method Summary
 javax.swing.JLabel createLabel(java.lang.String textWithMnemonic)
          Creates and answers a label with an optional mnemonic.
 javax.swing.JComponent createSeparator(java.lang.String text)
          Creates and answers a label with separator on the left hand side.
 javax.swing.JComponent createSeparator(java.lang.String text, int alignment)
          Creates and answers a label with separator; useful to separate paragraphs in a panel.
 javax.swing.JLabel createTitle(java.lang.String textWithMnemonic)
          Creates and answers a label that uses the foreground color and font of a TitledBorder.
static DefaultComponentFactory getInstance()
          Returns the sole instance of this factory class.
static void setTextAndMnemonic(javax.swing.JLabel label, java.lang.String textWithMnemonic)
          Sets the text of the given label and optionally a mnemonic.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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 javax.swing.JLabel createLabel(java.lang.String textWithMnemonic)
Creates and answers a label with an optional mnemonic.

Specified by:
createLabel in interface ComponentFactory
Parameters:
textWithMnemonic - the label's text - may contain a mnemonic
Returns:
an label with optional mnemonic

createTitle

public javax.swing.JLabel createTitle(java.lang.String textWithMnemonic)
Creates and answers a label that uses the foreground color and font of a TitledBorder.

Specified by:
createTitle in interface ComponentFactory
Parameters:
textWithMnemonic - the title's text - may contain a mnemonic
Returns:
an emphasized title label

createSeparator

public javax.swing.JComponent createSeparator(java.lang.String text)
Creates and answers a label with separator on the left hand side. Useful to separate paragraphs in a panel. This is often a better choice than a TitledBorder.

The current implementation doesn't support component alignments.

Parameters:
text - the title's text
Returns:
a title label with separator on the side

createSeparator

public javax.swing.JComponent createSeparator(java.lang.String text,
                                              int alignment)
Creates and answers a label with separator; useful to separate paragraphs in a panel. This is often a better choice than a TitledBorder.

The current implementation doesn't support component alignments.

Specified by:
createSeparator in interface ComponentFactory
Parameters:
text - the title's text
alignment - text alignment: left, center, right
Returns:
a separator with title label

setTextAndMnemonic

public static void setTextAndMnemonic(javax.swing.JLabel label,
                                      java.lang.String textWithMnemonic)
Sets the text of the given label and optionally a mnemonic. The given text may contain mnemonic markers &&, where such a marker indicates that the following character shall be the mnemonic. If you want to use the \& charachter, just put two together, for example "&&&&".

Parameters:
label - the label that gets a mnemonic
textWithMnemonic - the text with optional mnemonic marker