com.jgoodies.uifextras.util
Class UIFactory

java.lang.Object
  extended by com.jgoodies.uifextras.util.UIFactory

public final class UIFactory
extends Object

A factory class that consists only of static methods to create frequently used Swing components.

Version:
$Revision: 1.9 $
Author:
Karsten Lentzsch

Method Summary
static JLabel createBoldLabel(String text)
          Creates and returns a JLabel with a bold font for the specified text.
static JLabel createBoldLabel(String text, int sizeIncrement)
          Creates and returns a JLabel with a bold font for the specified text and size increment, e.g. +3 is 3 pixel larger than the default.
static JLabel createBoldLabel(String text, int sizeIncrement, Color foreground)
          Creates and returns a JLabel with a bold font for the specified text, size increment, and foreground color.
static JLabel createBoldLabel(String text, int sizeIncrement, Color foreground, boolean antiAliased)
          Creates and returns a JLabel with a bold font for the specified text, size increment, foreground color, and anti-alias setting.
static JEditorPane createHTMLPane(boolean asynchronousLoad, boolean processEvents)
          Creates and returns an editor pane that shall be used for displaying HTML pages.
static JEditorPane createInfoEditorPane()
          Creates and returns a non-editable JEditorPane with editable background.
static JTextArea createInfoTextArea()
          Creates and returns a non-editable JTextArea with editable background.
static TableCellRenderer createLeftAlignedDefaultHeaderRenderer()
          Creates and returns a left aligned table header renderer.
static JTextArea createMultilineLabel(String text)
          Creates and returns a JTextArea that can be used as a label that spans over multiple lines.
static JLabel createPlainLabel(String text)
          Creates and returns a JLabel that uses a plain font.
static JLabel createPlainLabel(String text, Color foreground)
          Creates and returns a JLabel that uses a plain font and the given foreground color.
static JLabel createPlainLabel(String text, Color foreground, boolean antiAliased)
          Creates and returns a JLabel that uses a plain font and the given foreground color.
static JTextField createReadOnlyTextField()
          Creates and returns a JTextField, that is read-only.
static JScrollPane createStrippedScrollPane(Component component)
          Creates and returns a JScrollPane that has an empty border.
static JSplitPane createStrippedSplitPane(int orientation, Component comp1, Component comp2, double resizeWeight)
          Creates and returns a JSplitPane that has empty borders.
static JComponent createTablePanel(JTable table)
          Creates and returns a component that wraps a JTable with a JScrollPane, sets the viewport's background and appropriate corners.
static JTextArea createWrappedMultilineLabel(String text)
          Creates and returns a JTextArea that can be used as a label that spans over multiple lines.
static Color getLightBackground()
          Returns a light background Color.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

createBoldLabel

public static JLabel createBoldLabel(String text)
Creates and returns a JLabel with a bold font for the specified text.

Parameters:
text - the label's initial text
Returns:
a label that uses a bold font

createBoldLabel

public static JLabel createBoldLabel(String text,
                                     int sizeIncrement)
Creates and returns a JLabel with a bold font for the specified text and size increment, e.g. +3 is 3 pixel larger than the default.

Parameters:
text - the label's initial text
sizeIncrement - a pixel delta that is added to the default font size
Returns:
a label that uses a bold font

createBoldLabel

public static JLabel createBoldLabel(String text,
                                     int sizeIncrement,
                                     Color foreground)
Creates and returns a JLabel with a bold font for the specified text, size increment, and foreground color.

Parameters:
text - the label's initial text
sizeIncrement - a pixel delta that is added to the default font size
foreground - the label's foreground color
Returns:
a label that uses a bold font

createBoldLabel

public static JLabel createBoldLabel(String text,
                                     int sizeIncrement,
                                     Color foreground,
                                     boolean antiAliased)
Creates and returns a JLabel with a bold font for the specified text, size increment, foreground color, and anti-alias setting.

Parameters:
text - the label's initial text
sizeIncrement - a pixel delta that is added to the default font size
foreground - the label's foreground color
antiAliased - true to enable anti-aliasing
Returns:
a label that uses a bold font

createPlainLabel

public static JLabel createPlainLabel(String text)
Creates and returns a JLabel that uses a plain font. Should be used judiciously - overrides l&f settings.

Parameters:
text - the label's initial text
Returns:
a plain label that uses the control text color

createPlainLabel

public static JLabel createPlainLabel(String text,
                                      Color foreground)
Creates and returns a JLabel that uses a plain font and the given foreground color. Should be used judiciously - overrides l&f settings.

Parameters:
text - the label's initial text
foreground - the label's foreground color
Returns:
a plain label that uses the control text color

createPlainLabel

public static JLabel createPlainLabel(String text,
                                      Color foreground,
                                      boolean antiAliased)
Creates and returns a JLabel that uses a plain font and the given foreground color. Should be used judiciously - override l&f settings.

Parameters:
text - the label's initial text
foreground - the label's foreground color
antiAliased - true to enable anti-aliasing
Returns:
a plain label that uses the control text color

createReadOnlyTextField

public static JTextField createReadOnlyTextField()
Creates and returns a JTextField, that is read-only.

TODO: move to BasicComponentFactory

Returns:
a read-only text field

createMultilineLabel

public static JTextArea createMultilineLabel(String text)
Creates and returns a JTextArea that can be used as a label that spans over multiple lines. Requires hand-wrapped text.

Parameters:
text - the text component's initial text - requires newlines
Returns:
a text component that renders the given text in multiple lines
See Also:
createWrappedMultilineLabel(String)

createWrappedMultilineLabel

public static JTextArea createWrappedMultilineLabel(String text)
Creates and returns a JTextArea that can be used as a label that spans over multiple lines. Will wrap lines at words.

Parameters:
text - the text component's initial text
Returns:
a text component that renders the given text in multiple lines
See Also:
createMultilineLabel(String)

createInfoEditorPane

public static JEditorPane createInfoEditorPane()
Creates and returns a non-editable JEditorPane with editable background.

Returns:
a non-editable JEditorPane
Since:
1.6

createInfoTextArea

public static JTextArea createInfoTextArea()
Creates and returns a non-editable JTextArea with editable background.

Returns:
a non-editable JTextArea
Since:
1.6

createHTMLPane

public static JEditorPane createHTMLPane(boolean asynchronousLoad,
                                         boolean processEvents)
Creates and returns an editor pane that shall be used for displaying HTML pages. Uses the specified properties to set whether we load synchronously or asynchronously, and process events, or shield the pane from processing events.

Parameters:
asynchronousLoad - true to load asynchronously, false for synchronous
processEvents - true to process events
Returns:
an editor pane that can display HTML pages

createTablePanel

public static JComponent createTablePanel(JTable table)
Creates and returns a component that wraps a JTable with a JScrollPane, sets the viewport's background and appropriate corners.

Parameters:
table - the table to be wrapped
Returns:
the table wrapped by a scrollpane

createLeftAlignedDefaultHeaderRenderer

public static TableCellRenderer createLeftAlignedDefaultHeaderRenderer()
Creates and returns a left aligned table header renderer.

Returns:
a table cell renderer for left aligned headers

createStrippedSplitPane

public static JSplitPane createStrippedSplitPane(int orientation,
                                                 Component comp1,
                                                 Component comp2,
                                                 double resizeWeight)
Creates and returns a JSplitPane that has empty borders. Useful to avoid duplicate decorations, for example if the split pane is contained by other components that already provide a border.

Parameters:
orientation - the split pane's orientation: horizontal or vertical
comp1 - the top/left component
comp2 - the bottom/right component
resizeWeight - indicates how to distribute extra space
Returns:
a split panes that has an empty border

createStrippedScrollPane

public static JScrollPane createStrippedScrollPane(Component component)
Creates and returns a JScrollPane that has an empty border. Useful to avoid duplicate decorations, for example if the scrollpane is contained by other components that already provide a border.

Parameters:
component - the component to wrap
Returns:
the scrollpane that has no border

getLightBackground

public static Color getLightBackground()
Returns a light background Color. Computes and answers a Color that has a minimum and maximum brightness and is slightly darker than the specified Color.

Returns:
a color used as a background that is slightly darker than the color used by controls


Copyright © 2000-2008 JGoodies Karsten Lentzsch. All Rights Reserved.