|
Components |
|
| |||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
com.sas.swing.visuals.wizard2.ButtonNavigationPanel
public class ButtonNavigationPanel
The ButtonNavigationPanel is a panel containing buttons designed to navigate through the pages of a Wizard object. The default constructor creates a panel with Back, Next, Cancel, and Help buttons, with the buttons justified to the right side of the container. Another constuctor is provided to create a ButtonNavigationPanel with custom buttons.
Two addButton methods are provided to add custom buttons, one allowing a button to be added at a specified index within the container. Buttons can be removed from the panel with the removeButton method, and access to buttons is achieved through the getButton method.
ButtonNavigationPanel uses a ButtonLayout layout manager, which allows the spacing between the buttons to be controlled, as well as the ability to justify the buttons to the left or right side. A constraint parameter is used by the ButtonLayout to specify the amount of space to place to the right of the buttons. This space can be specified as a fixed amount (in number of pixels), a percentage of the leftover space, and the remainder of leftover space. See class ButtonLayout for detailed information.
ButtonNavigationPanel implements the ActionListener interface, and handles the actionEvents generated by the
buttons it contains. ActionEvents generated by buttons having action commands BACK_COMMAND and
NEXT_FINISH_COMMAND call on the deck
object to show previous and next pages respectively.
The action commands of other buttons firing ActionEvents are forwarded to the Wizard handleButtonCommand method for handling. If custom buttons are added to the ButtonNavigationPanel, then the Wizard handleButtonCommand method should be overridden to provide the desired functionality.
The enableButtons method is called to determine whether or not each button contained in the ButtonNavigationPanel object
should be enabled, and set accordingly. It is internally called whenever a page in the wizard
is shown, to correctly
enable the buttons for that particular page. This method can also be called directly whenever the enabled state
of a button requires change.
A button's enabled state is determined by calling the current page's isButtonEnabled method. The enableButtons method disables the "Back" button, having action command BACK_COMMAND, on the first page of the wizard. Also, on the last page of the wizard, the "Next" button, with action command NEXT_FINISH_COMMAND, is disabled if a custom "Finish" button, with an action command of FINISH_COMMAND is contained in the panel. Otherwise, if there is no custom "Finish" button, the text on the button with action command NEXT_FINISH_COMMAND is changed to "Finish".
Wizard
,
ButtonLayout
,
Serialized FormField Summary | |
---|---|
static java.lang.String |
ACTION_COMMAND
The key used for storing the action command for a button defined by an Action. |
static java.lang.String |
BACK_COMMAND
The action command associated with the default "Back" button. |
static java.lang.String |
CANCEL_COMMAND
The action command associated with the default "Cancel" button. |
protected WizardPageDeck |
deck
A WizardPageDeck object containing pages through which the buttons in this ButtonNavigationPanel control the navigation. |
static java.lang.String |
FINISH_COMMAND
The action command associated with a custom "Finish" button. |
static java.lang.String |
HELP_COMMAND
The action command associated with the default "Help" button. |
protected ButtonLayout |
layout
The layout manager for this ButtonNavigationPanel |
static java.lang.String |
NEXT_FINISH_COMMAND
The action command associated with the default "Next" button. |
static java.lang.String |
RB_KEY
|
Constructor Summary | |
---|---|
ButtonNavigationPanel(WizardPageDeck deck)
Creates a ButtonNavigationPanel with Back, Next, Cancel, and Help buttons, created from the corresponding Actions defined in the Wizard class. |
|
ButtonNavigationPanel(WizardPageDeck deck,
javax.swing.Action[] action,
java.lang.Object[] constraint)
|
|
ButtonNavigationPanel(WizardPageDeck deck,
java.lang.String[] buttonText,
java.lang.String[] actionCommand,
java.lang.Object[] constraint)
Creates a right aligned ButtonNavigationPanel containing the specified buttons. |
Method Summary | |
---|---|
void |
actionPerformed(java.awt.event.ActionEvent event)
Handles ActionEvents fired from buttons in the ButtonNavigationPanel . |
void |
addButton(javax.swing.Action a,
java.lang.Object constraint)
Creates a new button attached to the specified Action object and appends it to the end of this container. |
void |
addButton(javax.swing.Action a,
java.lang.Object constraint,
int index)
Creates a new button attached to the specified Action object and adds it to this container at the specified index. |
void |
addButton(java.lang.String buttonText,
java.lang.String actionCommand,
java.lang.Object constraint)
Adds a button with the specified button text, action command, and spacing constraint to the end of this container |
void |
addButton(java.lang.String buttonText,
java.lang.String actionCommand,
java.lang.Object constraint,
int index)
Adds a button with the specified button text, action command, and spacing constraint at the specified index. |
protected javax.swing.JButton |
createButton(javax.swing.Action action)
|
protected javax.swing.JButton |
createButton(java.lang.String buttonText,
java.lang.String actionCommand)
Factory method which creates a JButton to be used in the ButtonNavigationPanel. |
void |
createLayout()
Creates the layout manager for this ButtonNavigationPanel. |
void |
createVisuals(javax.swing.Action[] action,
java.lang.Object[] constraint)
|
void |
createVisuals(java.lang.String[] buttonText,
java.lang.String[] actionCommand,
java.lang.Object[] constraint)
Calls method createLayout to create the layout manager for the ButtonNavigationPanel. |
void |
enableButtons()
Verifies the enabled state of each button for a page, and enables them accordingly. |
javax.swing.JButton |
getButton(java.lang.String actionCommand)
Returns the button from the ButtonNavigationPanel with the specified action command. |
void |
removeButton(java.lang.String actionCommand)
Removes the specified button from the ButtonNavigationPanel. |
Field Detail |
---|
public static final java.lang.String RB_KEY
protected WizardPageDeck deck
protected ButtonLayout layout
public static final java.lang.String ACTION_COMMAND
public static final java.lang.String NEXT_FINISH_COMMAND
public static final java.lang.String BACK_COMMAND
public static final java.lang.String CANCEL_COMMAND
public static final java.lang.String HELP_COMMAND
public static final java.lang.String FINISH_COMMAND
Constructor Detail |
---|
public ButtonNavigationPanel(WizardPageDeck deck, java.lang.String[] buttonText, java.lang.String[] actionCommand, java.lang.Object[] constraint)
deck
- the WizardPageDeck object containing pages through which the buttons in this ButtonNavigationPanel control
the navigationbuttonText
- an array of Strings containing the text to be displayed on the buttonsactionCommand
- an array of Strings containing the buttons' associated action commandsconstraint
- an array of Objects (Integer, Float, or String) specifying the amount of space to place to the right
of the buttonspublic ButtonNavigationPanel(WizardPageDeck deck)
Wizard
class. The respective action commands associated with these
buttons are BACK_COMMAND, NEXT_FINISH_COMMAND, CANCEL_COMMAND, and HELP_COMMAND. The buttons are right
aligned within the panel.
deck
- the WizardPageDeck object containing pages through which the buttons in this ButtonNavigationPanel control
the navigationpublic ButtonNavigationPanel(WizardPageDeck deck, javax.swing.Action[] action, java.lang.Object[] constraint)
Method Detail |
---|
public void addButton(java.lang.String buttonText, java.lang.String actionCommand, java.lang.Object constraint)
buttonText
- the text to be displayed on the buttonactionCommand
- the button's associated action commandconstraint
- an Integer, Float, or String object which specifies the amount of space to place to the right
of the buttonButtonLayout
public void addButton(java.lang.String buttonText, java.lang.String actionCommand, java.lang.Object constraint, int index)
buttonText
- the text to be displayed on the buttonactionCommand
- the button's associated action commandconstraint
- an Integer, Float, or String object which specifies the amount of space to place to the right
of the buttonindex
- the position at which to insert the button, or -1 to insert the button at the endButtonLayout
public void addButton(javax.swing.Action a, java.lang.Object constraint)
Action
object and appends it to the end of this container.
The action command for the button will be retrieved from the Action object through the
key ACTION_COMMAND
. If this value has not been set, then the action command will
be set to Action.NAME.
a
- the Action
for the button to be addedconstraint
- an Integer, Float, or String object which specifies the amount of space to place to the right
of the buttonAction
public void addButton(javax.swing.Action a, java.lang.Object constraint, int index)
Action
object and adds it to this container at the specified index.
a
- the Action
for the button to be addedconstraint
- an Integer, Float, or String object which specifies the amount of space to place to the right
of the buttonindex
- the position at which to insert the button, or -1 to insert the button at the endAction
public void removeButton(java.lang.String actionCommand)
actionCommand
- the action command associated with the button to remove from the ButtonNavigationPanelpublic javax.swing.JButton getButton(java.lang.String actionCommand)
actionCommand
- the action command associated with the button to return
protected javax.swing.JButton createButton(java.lang.String buttonText, java.lang.String actionCommand)
protected javax.swing.JButton createButton(javax.swing.Action action)
public void enableButtons()
If the first page of the wizard is being shown, then the button with the action command BACK_COMMAND is disabled.
If the last page is being shown, this method changes the text on the "Next" button with action command NEXT_FINISH_COMMAND to "Finish", only if a custom "Finish" button with action command FINISH_COMMAND is not contained in the panel. If there is a custom "Finish" button, then the button with action command NEXT_FINISH_COMMAND is disabled.
WizardPageInterface.isButtonEnabled(java.lang.String)
public void actionPerformed(java.awt.event.ActionEvent event)
ButtonNavigationPanel
. The previous page in the wizard path is shown when an ActionEvent
is received from the button with the action command BACK_COMMAND
. Likewise, the next page in the wizard path is shown when an
ActionEvent is received from the button with the action command NEXT_FINISH_COMMAND
. In either case, the current page's hidePage
method
is called and returns true
before another page is shown. ActionEvents received from other buttons will be routed to the Wizard handleButtonCommand
method for handling.
actionPerformed
in interface java.awt.event.ActionListener
event
- the ActionEvent to be handledpublic void createLayout()
createVisuals
. The layout manager used is the ButtonLayout, with the justification
set to Orientations.RIGHT.
ButtonLayout
public void createVisuals(java.lang.String[] buttonText, java.lang.String[] actionCommand, java.lang.Object[] constraint)
createLayout
to create the layout manager for the ButtonNavigationPanel.
Creates and adds the buttons specified by buttonText
, actionCommand
, and
constraints
to the ButtonNavigationPanel.
buttonText
- an array of Strings specifying the text to be shown on the buttonsactionCommand
- an array of Strings specifying the action commands for the buttonsconstraints
- an array of Objects specifying the spacing to place to the right of
the buttonsButtonLayout
,
createLayout()
public void createVisuals(javax.swing.Action[] action, java.lang.Object[] constraint)
|
Components |
|
| |||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |