com.jgoodies.uif.builder
Class I15dPanelBuilder2

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

public class I15dPanelBuilder2
extends com.jgoodies.forms.builder.AbstractI15dPanelBuilder

A general purpose panel builder that uses the FormLayout to lay out JPanels. In addition to its superclass PanelBuilder this class provides convenience behavior to map resource keys to their associated internationalized (i15d) strings when adding labels, titles and titled separators.

The localized texts used in methods #addI15dLabel and #addI15dTitle can contain an optional mnemonic marker. The mnemonic and mnemonic index are indicated by a single ampersand (&). For example "&Save", or "Save &as". To use the ampersand itself, duplicate it, for example "Look&&Feel".

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

Version:
$Revision: 1.4 $
Author:
Karsten Lentzsch
See Also:
ResourceMap

Constructor Summary
I15dPanelBuilder2(com.jgoodies.forms.layout.FormLayout layout, ResourceMap resourceMap)
          Constructs a I15dPanelBuilder2 for the given layout and resource bundle.
I15dPanelBuilder2(com.jgoodies.forms.layout.FormLayout layout, ResourceMap resourceMap, JPanel panel)
          Constructs a I15dPanelBuilder2 for the given FormLayout, resource bundle, 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.
protected  String getI15dString(String resourceKey)
          Looks up and returns the internationalized (i15d) string for the given resource key from the ResourceMap.
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.
 
Methods inherited from class com.jgoodies.forms.builder.AbstractI15dPanelBuilder
addI15dLabel, addI15dLabel, addI15dLabel, addI15dSeparator, addI15dSeparator, addI15dTitle, addI15dTitle, isDebugToolTipsEnabled, setDebugToolTipsEnabled
 
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

I15dPanelBuilder2

public I15dPanelBuilder2(com.jgoodies.forms.layout.FormLayout layout,
                         ResourceMap resourceMap)
Constructs a I15dPanelBuilder2 for the given layout and resource bundle. Uses an instance of JPanel as layout container.

Parameters:
layout - the FormLayout used to layout the container
resourceMap - the ResourceMap used to look up i15d strings
Throws:
NullPointerException - if resourceMap is null

I15dPanelBuilder2

public I15dPanelBuilder2(com.jgoodies.forms.layout.FormLayout layout,
                         ResourceMap resourceMap,
                         JPanel panel)
Constructs a I15dPanelBuilder2 for the given FormLayout, resource bundle, and layout container.

Parameters:
layout - the FormLayout used to layout the container
resourceMap - the ResourceMap used to look up i15d strings
panel - the layout container
Throws:
NullPointerException - if resourceMap is null
Method Detail

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 PanelBuilder2.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 PanelBuilder2.getLabelForFeatureEnabledDefault(). It is globally disabled by default.

Parameters:
b - true for enabled, false for disabled

getI15dString

protected String getI15dString(String resourceKey)
Looks up and returns the internationalized (i15d) string for the given resource key from the ResourceMap.

Specified by:
getI15dString in class com.jgoodies.forms.builder.AbstractI15dPanelBuilder
Parameters:
resourceKey - the key to look for in the resource map
Returns:
the associated internationalized string, or the resource key itself in case of a missing resource

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.