com.jgoodies.uif.builder
Class PanelBuilder2

java.lang.Object
  extended by com.jgoodies.forms.builder.AbstractFormBuilder
      extended by com.jgoodies.forms.builder.PanelBuilder
          extended by com.jgoodies.uif.builder.PanelBuilder2

public class PanelBuilder2
extends com.jgoodies.forms.builder.PanelBuilder

Adds a feature to its superclass PanelBuilder that labels with a mnemonic are associated with the next added focusable component. This feature shall be moved to the PanelBuilder.

Note: This class has been temporarily added to the UIF. The support for automatically associating added focusable components with a previously added label that has a mnemonic will be moved to the Forms library core in the Forms 1.3.

Version:
$Revision: 1.2 $
Author:
Karsten Lentzsch

Constructor Summary
PanelBuilder2(com.jgoodies.forms.layout.FormLayout layout)
          Constructs a PanelBuilder2 for the given layout.
PanelBuilder2(com.jgoodies.forms.layout.FormLayout layout, JPanel panel)
          Constructs a PanelBuilder2 for the given FormLayout and layout container.
 
Method Summary
 Component add(Component component, com.jgoodies.forms.layout.CellConstraints cellConstraints)
          Adds a component to the panel using the given cell constraints.
static boolean getLabelForFeatureEnabledDefault()
          Returns the global default for the enablement of the setLabelFor feature.
protected  boolean isLabelForApplicable(Component component)
          Checks and answers whether the given component shall be set as component for a previously added label with mnemonic using JLabel.setLabelFor(Component).
 boolean isLabelForFeatureEnabled()
          Returns whether the setLabelFor feature is enabled for this PanelBuilder.
 void setLabelForFeatureEnabled(boolean b)
          Enables or disables the setLabelFor feature for this PanelBuilder.
static void setLabelForFeatureEnabledDefault(boolean b)
          Sets the default value for the setLabelFor feature enablement.
 
Methods inherited from class com.jgoodies.forms.builder.PanelBuilder
add, addLabel, addLabel, addLabel, addLabel, addSeparator, addSeparator, addSeparator, addSeparator, addTitle, addTitle, addTitle, getComponentFactory, getPanel, setBackground, setBorder, setComponentFactory, setDefaultDialogBorder, setOpaque
 
Methods inherited from class com.jgoodies.forms.builder.AbstractFormBuilder
add, add, appendColumn, appendColumn, appendGlueColumn, appendGlueRow, appendLabelComponentsGapColumn, appendParagraphGapRow, appendRelatedComponentsGapColumn, appendRelatedComponentsGapRow, appendRow, appendRow, appendUnrelatedComponentsGapColumn, appendUnrelatedComponentsGapRow, cellConstraints, createLeftAdjustedConstraints, getColumn, getColumnCount, getColumnIncrementSign, getContainer, getLayout, getLeadingColumn, getRow, getRowCount, isLeftToRight, nextColumn, nextColumn, nextLine, nextLine, nextRow, nextRow, setAlignment, setBounds, setColumn, setColumnSpan, setExtent, setHAlignment, setLeftToRight, setOrigin, setRow, setRowSpan, setVAlignment
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PanelBuilder2

public PanelBuilder2(com.jgoodies.forms.layout.FormLayout layout)
Constructs a PanelBuilder2 for the given layout. Uses an instance of JPanel as layout container with the given layout as layout manager.

Parameters:
layout - the FormLayout to use

PanelBuilder2

public PanelBuilder2(com.jgoodies.forms.layout.FormLayout layout,
                     JPanel panel)
Constructs a PanelBuilder2 for the given FormLayout and layout container.

Parameters:
layout - the FormLayout to use
panel - the layout container to build on
Method Detail

getLabelForFeatureEnabledDefault

public static boolean getLabelForFeatureEnabledDefault()
Returns the global default for the enablement of the setLabelFor feature. This can be overridden per PanelBuilder using setLabelForFeatureEnabled(boolean). The feature is globally disabled by default.

Returns:
true for globally enabled, false for globally disabled

setLabelForFeatureEnabledDefault

public static void setLabelForFeatureEnabledDefault(boolean b)
Sets the default value for the setLabelFor feature enablement. This can be overridden per PanelBuilder using setLabelForFeatureEnabled(boolean). The default value is used to set the initial PanelBuilder setting for this feature. The feature is globally disabled by default.

Parameters:
b - true for globally enabled, false for globally disabled

isLabelForFeatureEnabled

public boolean isLabelForFeatureEnabled()
Returns whether the setLabelFor feature is enabled for this PanelBuilder. The value is initialized from the global default value for this feature getLabelForFeatureEnabledDefault(). It is globally disabled by default.

Returns:
true for enabled, false for disabled

setLabelForFeatureEnabled

public void setLabelForFeatureEnabled(boolean b)
Enables or disables the setLabelFor feature for this PanelBuilder. The value is initialized from the global default value getLabelForFeatureEnabledDefault(). It is globally disabled by default.

Parameters:
b - true for enabled, false for disabled

add

public Component add(Component component,
                     com.jgoodies.forms.layout.CellConstraints cellConstraints)
Adds a component to the panel using the given cell constraints. In addition to the superclass behavior, this implementation tracks the most recently label that has mnemonic, and associates it with the next added focusable component.

TODO: Consider to clear the most recently added mnemonic label if another label is added - even if the latter has no mnemonic set.

Overrides:
add in class com.jgoodies.forms.builder.AbstractFormBuilder
Parameters:
component - the component to add
cellConstraints - the component's cell constraints
Returns:
the added component
See Also:
isLabelForFeatureEnabled(), isLabelForApplicable(Component)

isLabelForApplicable

protected boolean isLabelForApplicable(Component component)
Checks and answers whether the given component shall be set as component for a previously added label with mnemonic using JLabel.setLabelFor(Component). This default implementation just checks whether the component is focusable. Subclasses may override.

Parameters:
component - the component to be checked
Returns:
true if focusable, false otherwise


Copyright © 2000-2008 JGoodies Karsten Lentzsch. All Rights Reserved.