Package io.codeworth.panelmatic
Interface PanelBuilder
- All Known Implementing Classes:
AbstractPanelBuilder,GbPanelBuilder
public interface PanelBuilder
The "Main interface" for this library. Builds panels based on the calls fro the client code.
Instances implementing this interface are normally created by PanelBuilderFactorys
and managed by the static methods of PanelMatic class.
- Author:
- michaelbar-sinai
- See Also:
PanelBuilderFactory.build(),PanelMatic.begin(io.codeworth.panelmatic.PanelMaticComponentCustomizer[])
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classPanelBuilder.HeaderLevelDescribes the title level. -
Method Summary
Modifier and Type Method Description PanelBuilderadd(String title, JComponent comp, BehaviorModifier... modifiers)PanelBuilderadd(Icon icn, String title, JComponent comp, BehaviorModifier... modifiers)PanelBuilderadd(JComponent comp, BehaviorModifier... modifiers)PanelBuilderadd(JComponent titleComp, JComponent comp, BehaviorModifier... modifiers)PanelBuilderaddFlexibleSpace()Adds an empty space that stretches to take any extra space available.PanelBuilderaddHeader(PanelBuilder.HeaderLevel hx, String title, JComponent... comps)PanelBuilderaddHeader(PanelBuilder.HeaderLevel hx, Icon icn, String title, JComponent... comps)PanelBuilderbegin(PanelMaticComponentCustomizer... custsForCurrentBuild)Prepares the builder to get a panel using internally-created container.PanelBuilderbegin(JComponent basePanel, PanelMaticComponentCustomizer... custsForCurrentBuild)Prepares the builder to get a panel using the suppliedJComponentas the top-level container.JComponentget(PanelPostProcessor... pp)Finalizes the build, and returns the built panel.List<PanelMaticComponentCustomizer>getCustomizerChain()Allows access to the chain ofPanelMaticComponentCustomizers that customize components before adding them to the built panel.voidsetBuilderPool(BuilderPool aPool)Sets the pool into which the builder will return when done.
-
Method Details
-
begin
Prepares the builder to get a panel using internally-created container. When possible, you should use this method, rather thanbegin(javax.swing.JComponent, org.panelmatic.PanelMaticComponentCustomizer[]), as it is guaranteed to work.- Parameters:
custsForCurrentBuild- Component customizers that are prepended to the normal component customizers, for this get only (untilget(org.panelmatic.PanelPostProcessor[])is called).- Returns:
thisbuilder.
-
begin
Prepares the builder to get a panel using the suppliedJComponentas the top-level container. Use when laying-out existing panels. The builder would probably try to set properties on the component, make sure that panel can handle those changes (e.g setting of aLayoutManager.- Parameters:
basePanel- The component to be used as container.custsForCurrentBuild- Component customizers that are prepended to the normal component customizers, for this get only (untilget(org.panelmatic.PanelPostProcessor[])is called).- Returns:
thisbuilder.
-
add
-
add
-
add
-
add
-
addHeader
-
addHeader
-
addFlexibleSpace
PanelBuilder addFlexibleSpace()Adds an empty space that stretches to take any extra space available.- Returns:
thisbuilder.
-
get
Finalizes the build, and returns the built panel. The builder returns to its pool. After calling this method, the client code can no longer use the builder! To obtain a new builder, call on ofPanelMatic]'sbegin()methods- Parameters:
pp- optional post processors for the built panel.- Returns:
- the built component.
-
getCustomizerChain
List<PanelMaticComponentCustomizer> getCustomizerChain()Allows access to the chain of
PanelMaticComponentCustomizers that customize components before adding them to the built panel.To add a customizer, use
builder.getCustomizerChain().add( cust );Note that since the builders are pooled, changes made to a builder obtained byPanelMatic.begin(...)might not effect other builders obtained the same way. To ensure all builders are changed, consider implementing aPanelBuilderFactoryand calling this method on thePanelBuilderFactory.build()method.- Returns:
- The chain of customizers.
-
setBuilderPool
Sets the pool into which the builder will return when done. Normally client code should not call this method.- Parameters:
aPool- the pool this builder should return to when done building.
-