com.jgoodies.forms.builder
Class AbstractBuilder

java.lang.Object
  extended by com.jgoodies.forms.builder.AbstractBuilder
Direct Known Subclasses:
AbstractButtonPanelBuilder, AbstractFormBuilder

public abstract class AbstractBuilder
extends Object

An abstract class that minimizes the effort required to implement non-visual builders that use the FormLayout.

Builders hide details of the FormLayout and provide convenience behavior that assists you in constructing a form, bar, stack. This class provides a cell cursor that helps you traverse a form while you add components. Also, it offers several methods to append custom and logical columns and rows.

Version:
$Revision: 1.3 $
Author:
Karsten Lentzsch
See Also:
ButtonBarBuilder, ButtonStackBuilder, PanelBuilder, I15dPanelBuilder, DefaultFormBuilder

Field Summary
protected  CellConstraints currentCellConstraints
          Holds an instance of CellConstraints that will be used to specify the location, extent and alignments of the component to be added next.
 
Constructor Summary
protected AbstractBuilder(FormLayout layout, Container container)
          Constructs an AbstractBuilder for the given FormLayout and layout container.
 
Method Summary
protected  ComponentFactory createComponentFactory()
          Invoked when the per-instance component factory is lazily initialized.
 int getColumnCount()
          Returns the number of columns in the form.
 ComponentFactory getComponentFactory()
          Returns this builder's component factory.
static ComponentFactory getComponentFactoryDefault()
          Returns the factory that is used as default for new builder's as they are created.
 Container getContainer()
          Returns the container used to build the form.
 FormLayout getLayout()
          Returns the FormLayout instance used to build this form.
 int getRowCount()
          Returns the number of rows in the form.
 void setComponentFactory(ComponentFactory newFactory)
          Sets a new component factory for this builder, overriding the default as provided by getComponentFactoryDefault().
static void setComponentFactoryDefault(ComponentFactory factory)
          Sets the global default that is used to initialize the per-instance component factory.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

currentCellConstraints

protected final CellConstraints currentCellConstraints
Holds an instance of CellConstraints that will be used to specify the location, extent and alignments of the component to be added next.

Constructor Detail

AbstractBuilder

protected AbstractBuilder(FormLayout layout,
                          Container container)
Constructs an AbstractBuilder for the given FormLayout and layout container.

Parameters:
layout - the FormLayout to use
container - the layout container
Throws:
NullPointerException - if layout or container is null
Method Detail

getComponentFactoryDefault

public static ComponentFactory getComponentFactoryDefault()
Returns the factory that is used as default for new builder's as they are created. This default itself is lazily initialized as the DefaultComponentFactory.

Returns:
the factory that is used as default for new builder instances

setComponentFactoryDefault

public static void setComponentFactoryDefault(ComponentFactory factory)
Sets the global default that is used to initialize the per-instance component factory.

Parameters:
factory - the factory to be used for all new builder instances that do not override the default

getContainer

public final Container getContainer()
Returns the container used to build the form.

Returns:
the layout container

getLayout

public final FormLayout getLayout()
Returns the FormLayout instance used to build this form.

Returns:
the FormLayout

getColumnCount

public final int getColumnCount()
Returns the number of columns in the form.

Returns:
the number of columns

getRowCount

public final int getRowCount()
Returns the number of rows in the form.

Returns:
the number of rows

getComponentFactory

public final ComponentFactory getComponentFactory()
Returns this builder's component factory. If no factory has been set before, it is lazily initialized from the global default as returned by getComponentFactoryDefault().

Returns:
the component factory
See Also:
setComponentFactory(ComponentFactory)

setComponentFactory

public final void setComponentFactory(ComponentFactory newFactory)
Sets a new component factory for this builder, overriding the default as provided by getComponentFactoryDefault().

Parameters:
newFactory - the component factory to be used for this builder
See Also:
getComponentFactory()

createComponentFactory

protected ComponentFactory createComponentFactory()
Invoked when the per-instance component factory is lazily initialized. This implementation returns the global default factory.

Subclasses may override to use a factory other than the global default. However, in most cases it is sufficient to just set a new gobal default using setComponentFactoryDefault(ComponentFactory).

Returns:
the factory used during the lazy initialization of the per-instance component factory


Copyright © 2002-2012 JGoodies Karsten Lentzsch. All Rights Reserved.