Package io.codeworth.panelmatic
Class PanelMatic
- java.lang.Object
-
- io.codeworth.panelmatic.PanelMatic
-
public class PanelMatic extends Object
A "starter class" for the PanelMatic system. Use the static method to start building new panels.
Customizing the created panels can be done in a few ways:
- Passing
PanelMaticComponentCustomizers to thebegin(org.panelmatic.PanelMaticComponentCustomizer[])method. - Implementing a
PanelBuilderComponentFactoryand setting it as the component factory of thepanelBuilder. - Implementing a
PanelBuilderFactoryand customizing the createdPanelBuilders when building them. Then tellingPanelMaticto use the factory viasetBuilderFactory(org.panelmatic.PanelBuilderFactory). - Implementing the
PanelBuilderinterface. This would also entail creating a factory.
This class holds a
PanelBuilderFactoryand uses it to createPanelBuilders when needed. The panel builders are re-used via aBuilderPool.As building panels can only take place in the Event Dispatch Thread, no thread-safety precautions were taken.
Simple Usage Example
JComponent panel = PanelMatic.begin() .addHeader( HeaderLevel.H1, "User Details") .add("Name", nameField ) .add("Address", addressField ) .add( optInCheckBox ) .add( memoTextArea, Modifiers.GROW ) .get();- Author:
- michaelbar-sinai
- Passing
-
-
Constructor Summary
Constructors Constructor Description PanelMatic()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static PanelBuilderbegin(PanelMaticComponentCustomizer... custsForCurrentBuild)Retrieves a builder (either pooled or new) and returns it.static PanelBuilderbegin(JComponent basePanel, PanelMaticComponentCustomizer... custsForCurrentBuild)Retrieves a builder (either pooled or new) and returns it.static ComponentOrientationgetComponentOrientation()static ResourceBundlegetLocalizationBundle()static voidsetBuilderFactory(PanelBuilderFactory pbf)Sets the panel builder factory and creates a new builder pool.static voidsetComponentOrientation(ComponentOrientation anOrientation)Sets the component orientation of the created panels.static voidsetLocalizationBundle(ResourceBundle aBundle)Sets the localization resource bundle for the builders.
-
-
-
Method Detail
-
setBuilderFactory
public static void setBuilderFactory(PanelBuilderFactory pbf)
Sets the panel builder factory and creates a new builder pool.- Parameters:
pbf- The new builder factory. Cannot benull- Throws:
IllegalArgumentException- ifpbfisnull.
-
begin
public static PanelBuilder begin(PanelMaticComponentCustomizer... custsForCurrentBuild)
Retrieves a builder (either pooled or new) and returns it. The returned builder is using its own panel as the top-level panel.- Parameters:
custsForCurrentBuild- Component customizers that are prepended to the normal component customizers, for this get only (untilPanelBuilder.get(org.panelmatic.PanelPostProcessor[])is called).- Returns:
- A panel builder ready to get a new panel.
-
begin
public static PanelBuilder begin(JComponent basePanel, PanelMaticComponentCustomizer... custsForCurrentBuild)
Retrieves a builder (either pooled or new) and returns it. The returned builder is using the passed panel as the top level panel.- Parameters:
basePanel- The panel the builder will start building from.custsForCurrentBuild- Component customizers that are prepended to the normal component customizers, for this get only (untilPanelBuilder.get(org.panelmatic.PanelPostProcessor[])is called).- Returns:
- a builder ready to get a panel using
basePanelas the top-level container.
-
setLocalizationBundle
public static void setLocalizationBundle(ResourceBundle aBundle)
Sets the localization resource bundle for the builders. IfaBundleis notnull, the string parameter ofPanelBuilder's variousaddXXXmethods is interpreted as a key for a string in the passed bundle.If
aBundleisnull, that string parameter is displayed as-is.Note: PanelBuilders obtained before calling this method will not be affected.
- Parameters:
aBundle- the localization resource bundle, may benull.
-
getLocalizationBundle
public static ResourceBundle getLocalizationBundle()
-
setComponentOrientation
public static void setComponentOrientation(ComponentOrientation anOrientation)
Sets the component orientation of the created panels.Note: PanelBuilders obtained before calling this method will not be affected.
- Parameters:
anOrientation- the orientation of the built panels.
-
getComponentOrientation
public static ComponentOrientation getComponentOrientation()
-
-