Package io.codeworth.panelmatic.impl
Class DefaultComponentFactory
- java.lang.Object
-
- io.codeworth.panelmatic.impl.DefaultComponentFactory
-
- All Implemented Interfaces:
PanelBuilderComponentFactory
public class DefaultComponentFactory extends Object implements PanelBuilderComponentFactory
A no frills component factory. The labels are normalJLabels, The titles are all bold, sometimes italicized, and sized according to prominence. May serve as a good starting point for subclassing, when just a few teaks are needed.- Author:
- michael
-
-
Constructor Summary
Constructors Constructor Description DefaultComponentFactory()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected JLabelcreateHeaderLabel(String text, Icon icon, PanelBuilder.HeaderLevel hx)Create the label part of headers.JComponentgetComponentLabel(Icon icon, String text, JComponent component)Creates label that displays a label for a component.ComponentOrientationgetComponentOrientation()JComponentgetContainer()Create the container into which all the other components will go.JComponentgetHeader(PanelBuilder.HeaderLevel hx, Icon icon, String text, JComponent... items)Creates a new heading.protected <T extends JComponent>
Torient(T comp)Sets the orientation of the passed component.voidsetComponentOrientation(ComponentOrientation aComponentOrientation)Sets the orientation of the to-be-created components.
-
-
-
Method Detail
-
getComponentLabel
public JComponent getComponentLabel(Icon icon, String text, JComponent component)
Description copied from interface:PanelBuilderComponentFactoryCreates label that displays a label for a component. E.g, if there's a "given name" text field, the returned component would be displayed next to it, saying "Given name".- Specified by:
getComponentLabelin interfacePanelBuilderComponentFactory- Parameters:
icon- the icon the label should have.text- The text the label should have.component- the component this label is for.- Returns:
- a label with the passed text.
-
getHeader
public JComponent getHeader(PanelBuilder.HeaderLevel hx, Icon icon, String text, JComponent... items)
Description copied from interface:PanelBuilderComponentFactoryCreates a new heading.- Specified by:
getHeaderin interfacePanelBuilderComponentFactory- Parameters:
hx- How prominent this heading is.icon- The icon this heading should have.text- The text this heading should have.items- Widgets that appear on the header. e.g. controls that apply to the entire section below the header.- Returns:
- A heading component
- See Also:
PanelBuilder.HeaderLevel
-
createHeaderLabel
protected JLabel createHeaderLabel(String text, Icon icon, PanelBuilder.HeaderLevel hx)
Create the label part of headers. Additional components, if passed, are added and layed out bygetHeader(org.panelmatic.PanelBuilder.HeaderLevel, javax.swing.Icon, java.lang.String, javax.swing.JComponent[])istelf.- Parameters:
text- the test that will appear on the label.icon- the icon the label will havehx- header prominence.- Returns:
- a JLabel styled to be a header.
-
getContainer
public JComponent getContainer()
Description copied from interface:PanelBuilderComponentFactoryCreate the container into which all the other components will go.- Specified by:
getContainerin interfacePanelBuilderComponentFactory- Returns:
- the container into which all the other components will go.
-
orient
protected <T extends JComponent> T orient(T comp)
Sets the orientation of the passed component.- Type Parameters:
T- the type of the component.- Parameters:
comp- the component we want toComponent.setComponentOrientation(java.awt.ComponentOrientation)on- Returns:
comp, re-oriented.
-
getComponentOrientation
public ComponentOrientation getComponentOrientation()
- Specified by:
getComponentOrientationin interfacePanelBuilderComponentFactory
-
setComponentOrientation
public void setComponentOrientation(ComponentOrientation aComponentOrientation)
Description copied from interface:PanelBuilderComponentFactorySets the orientation of the to-be-created components.- Specified by:
setComponentOrientationin interfacePanelBuilderComponentFactory- Parameters:
aComponentOrientation- The orientation of the components-to-be.
-
-