public class TLcyCommonWidgetFactory extends Object
Factory to create some common user interface widgets. Use getSharedInstance()
to retrieve an instance of this factory, for example like this:
Component panel = TLcyCommonWidgetFactory.getSharedInstance().createTitledPanel(
"MyTitle", new JScrollPane( new JTree() ), new Insets( 10, 10, 10, 10 ) );
By making an extension of this factory, GUI widgets can be replaced application wide.
Those methods that are intended to replace or change widgets explicitly state in their
comments they can be overridden. Settings your custom extension can be done using the
setSharedInstance(TLcyCommonWidgetFactory)
method.
TLcyCommonWidgetFactory customExtension = ...;
TLcyCommonWidgetFactory.setSharedInstance( customExtension );
getSharedInstance()
Modifier | Constructor and Description |
---|---|
protected |
TLcyCommonWidgetFactory()
Creates a new
TLcyCommonWidgetFactory . |
Modifier and Type | Method and Description |
---|---|
Component |
createTitledPanel(String aTitle,
Component aContent)
Creates a new titled panel, with a left margin of 5 pixels and no outer spacing.
|
Component |
createTitledPanel(String aTitle,
Component aContent,
Insets aOuterSpacer)
Creates a new titled panel with a left margin of 5 pixels.
|
Component |
createTitledPanel(String aTitle,
Component aContent,
int aLeftMargin)
Creates a new titled panel without outer spacing.
|
Component |
createTitledPanel(String aTitle,
Component aContent,
int aLeftMargin,
Insets aOuterSpacer)
Creates a new titled panel.
|
Component |
createTitledSeparator(String aTitle)
Creates a horizontal separator with the given title.
|
static TLcyCommonWidgetFactory |
getSharedInstance()
Returns the shared
TLcyCommonWidgetFactory instance that can be used to
create some common GUI widgets. |
static void |
setSharedInstance(TLcyCommonWidgetFactory aSharedInstance)
Sets the shared
TLcyCommonWidgetFactory instance. |
protected TLcyCommonWidgetFactory()
TLcyCommonWidgetFactory
. Only extensions of this class need to use this
constructor, others should use getSharedInstance()
to retrieve an instance.public static TLcyCommonWidgetFactory getSharedInstance()
TLcyCommonWidgetFactory
instance that can be used to
create some common GUI widgets.TLcyCommonWidgetFactory
instance.setSharedInstance(TLcyCommonWidgetFactory)
public static void setSharedInstance(TLcyCommonWidgetFactory aSharedInstance)
TLcyCommonWidgetFactory
instance. Setting (an extension of)
TLcyCommonWidgetFactory
allows to redefine, application wide, the behavior of
certain methods of TLcyCommonWidgetFactory
.aSharedInstance
- The shared instance to use.getSharedInstance()
public Component createTitledPanel(String aTitle, Component aContent)
aTitle
- The title for the titled panel.aContent
- The content for the panelcreateTitledPanel(String, java.awt.Component, int, java.awt.Insets)
public Component createTitledPanel(String aTitle, Component aContent, int aLeftMargin)
aTitle
- The title for the titled panel.aContent
- The content for the panelaLeftMargin
- The left margin in pixels, used to have a horizontal shift between the left edge of the title
and the left edge of the component.createTitledPanel(String, java.awt.Component, int, java.awt.Insets)
public Component createTitledPanel(String aTitle, Component aContent, Insets aOuterSpacer)
aTitle
- The title for the titled panel.aContent
- The content for the panelaOuterSpacer
- The empty space added around the titled panel.createTitledPanel(String, java.awt.Component, int, java.awt.Insets)
public Component createTitledPanel(String aTitle, Component aContent, int aLeftMargin, Insets aOuterSpacer)
Component
. It looks like this:
aTitle ----------------
aContent
The shift between aTitle
and aContent
is specified by aLeftMargin
. The
spacing around the whole titled panel is specified by aOuterSpacer
.
Override this method to create a different look for titled panels.aTitle
- The title for the titled panel.aContent
- The content for the panelaLeftMargin
- The left margin in pixels, used to have a horizontal shift between the left edge of the title
and the left edge of the component.aOuterSpacer
- The empty space added around the titled panel.public Component createTitledSeparator(String aTitle)
aTitle
- The title to put on the separator.