com.jgoodies.forms.factories
Class DefaultComponentFactory

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

public class DefaultComponentFactory
extends Object
implements ComponentFactory

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

The texts used in methods #createLabel(String) and #createTitle(String) 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".

Version:
$Revision: 1.17 $
Author:
Karsten Lentzsch

Method Summary
 JLabel createLabel(String textWithMnemonic)
          Creates and returns a label with an optional mnemonic.
 JComponent createSeparator(String text)
          Creates and returns a labeled separator with the label in the left-hand side.
 JComponent createSeparator(String text, int alignment)
          Creates and returns a labeled separator.
 JLabel createTitle(String textWithMnemonic)
          Creates and returns a label that uses the foreground color 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
 

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.

 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
 

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

createTitle

public JLabel createTitle(String textWithMnemonic)
Creates and returns a label that uses the foreground color and font of a 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
 

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

createSeparator

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

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

createSeparator

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

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


Copyright © 2002-2004 JGoodies Karsten Lentzsch. All Rights Reserved.