borland Packages  Class Hierarchy  dbswing Package 

JdbNavToolBar component

java.lang.Object
   +----java.awt.Component
           +----java.awt.Container
                   +----javax.swing.JComponent
                           +----javax.swing.JToolBar
                                   +----com.borland.dbswing.JdbNavToolBar

About the JdbNavToolBar component

Variables  Constructors  Properties  Methods  Event Listeners

Implements AccessListener, NavigationListener, StatusListener, ActionListener, FocusListener, MouseListener, ImageObserver, MenuContainer, Serializable, EventListener, Accessible, ChangeListener, SwingConstants

Note: This is a feature of JBuilder Professional and Enterprise.

JdbNavToolBar is a JToolBar designed specifically for use with dbSwing data-aware components. JdbNavToolBar uses ToolBarLayout as its default layout manager, and its orientation is horizontal by default.

By default, a JdbNavToolbar contains the following 11 buttons for performing common actions such as navigating, editing, refreshing, and saving DataSet data:

JdbNavToolbar default buttons

Button Description
First Navigates to the first row of the DataSet. Calls DataSet.first() method.
Prior Navigates to the previous DataSet row. Calls DataSet.prior() method.
Next Navigates to the next DataSet row. Calls DataSet.next() method.
Last Navigates to the last row of the DataSet. Calls DataSet.last() method.
Insert Inserts a new row at the current DataSet row position. Calls DataSet.insertRow(true) method.
Delete Deletes the current DataSet row. Calls DataSet.deleteRow() method.
Post Commits changes to the current DataSet row. Calls DataSet.post() method.
Cancel Cancels changes being made to the current DataSet row. Calls DataSet.cancel() method.
Ditto Copies the previous row's contents to the current, newly inserted row. Calls DataSet.dittoRow(false) method.
Save Saves all changes to the DataSet. Calls DataSet.saveChanges() method.
Refresh Refreshes the contents of the DataSet. Calls DataSet.refresh() method.

JdbNavToolBar determines the DataSet it should navigate based upon the data-aware component that had focus most recently. If focus moves from a data-aware component to a component that is not data aware, JdbNavToolBar's current DataSet is the DataSet associated with the most recently focused data-aware component.

There are three ways to set up a JdbNavToolBar for use in your application:

Note that setting autoDetect to true clears the dataSetAwareComponents and the dataSet property values. Also, when both the dataSet and dataSetAwareComponents properties are set, the one set most recently is the one that takes precedence, the setting of the other one is cleared, and the autoDetect property is set to false.

Usually a JdbNavToolBar is initially disabled until a data-aware component gains focus. You can explicitly set the initially focused DataSet, however, by setting the focusedDataSet property. In the special case where only a single DataSet is auto-detected, that DataSet becomes the initially focused DataSet.

Hiding a button on the toolbar

To hide a button on the toolbar, set its corresponding buttonState property (for example, the buttonStateRefresh property for the Refresh button) to JdbNavToolBar.HIDDEN. Doing so hides the button unconditionally, regardless of the currently focused DataSet.

Customized button state for a particular DataSet

To enable, disable, or hide buttons depending upon the DataSet currently associated with the JdbNavToolBar, add a java.beans.PropertyChangeListener to JdbNavToolBar. When the focusedDataSet property change event occurs and its new value is the desired DataSet, set the buttonState properties (for example, buttonStateSave) on the JdbNavToolBar. Note, however, that once a button's corresponding buttonState property has been set, it must be explicitly restored to its default state (AUTO_ENABLED) to restore automatic enable/disable behavior.

Changing the button layout

By default, JdbNavToolBar uses ToolBarLayout as its default layout manager. ToolBarLayout combines the behaviors of the AWT FlowLayout and the GridLayout layout managers.

It is possible to change the layout to something other than ToolBarLayout. Note, however, that doing so may limit buttonState functionality; for example, not all layout managers support components that are not visible. In such a layout, a button with a HIDDEN buttonState may be invisible but still take up space on the toolbar. If the button should always remain hidden, however, you can remove it from the layout.

Customizing a button's text, icon, or tooltip

The buttons on the toolbar are deliberately declared with public access to allow you to customize their text, icon, or tooltip. You can also use the public reference to a button to remove it from the toolbar if necessary. Note that all buttons except for the priorButton and nextButton are JButtons. The priorButton and nextButton are RepeatButtons to facilitate repeat capability when the button is held down. To disable or customize the default repeat behavior, cast the public reference to the priorButton or nextButton to a RepeatButton, and set its repeat-related properties.

Adding custom buttons to the toolbar

You can add your own buttons to the toolbar by using the add() method. Note that JdbNavToolBar does not handle such a button's events or alter its state in any way. See Customizing button state for a particular DataSet for information on how to customize buttons for individual DataSets.

Changing the default button behavior

To change the default behavior of a toolbar button, you can either extend the JdbNavToolBar class and override the actionPerformed() method, or get the public reference to the button whose behavior you wish to change and remove JdbNavToolBar as an ActionListener on the button. You can then add your own ActionListener to the button, use getFocusedDataSet() to get the current DataSet, and execute your custom action on the currently focused DataSet.


JdbNavToolBar variables

Variables implemented in this class

Variables implemented in java.awt.Component

Variables implemented in javax.swing.JComponent

JdbNavToolBar constructors

JdbNavToolBar properties

*Read-only properties **Write-only properties

Properties implemented in this class

Properties implemented in java.awt.Component

Properties implemented in java.awt.Container

Properties implemented in java.lang.Object

Properties implemented in javax.swing.JComponent

Properties implemented in javax.swing.JToolBar

JdbNavToolBar methods

Methods implemented in this class

Methods implemented in java.awt.Component

Methods implemented in java.awt.Container

Methods implemented in java.lang.Object

Methods implemented in javax.swing.JComponent

Methods implemented in javax.swing.JToolBar

JdbNavToolBar event listeners


JdbNavToolBar variables

AUTO_ENABLED

  public static final int AUTO_ENABLED = 0
A buttonState property constant specifying that the button should be visible and automatically enabled/disabled.

AUTO_HIDDEN

  public static final int AUTO_HIDDEN = 1
A buttonState property constant specifying that the button should be automatically hidden when it is disabled, and made visible when it is enabled. Enabling and disabling happens automatically, according to the state of the current DataSet.

DISABLED

  public static final int DISABLED = 3
A buttonState property constant specifying that the button should always be disabled.

ENABLED

  public static final int ENABLED = 2
A buttonState property constant specifying that the button should always be enabled.

HIDDEN

  public static final int HIDDEN = 4
A buttonState property constant specifying that the button should always be hidden.

JdbNavToolBar constructors

JdbNavToolBar()

  public JdbNavToolBar()
Constructs a JdbNavToolBar by calling the null constructor of its superclass, adding the following buttons: FIRST, PRIOR, NEXT, LAST, INSERT, DELETE, POST, CANCEL, DITTO, SAVE, and REFRESH, and setting showRollover and showTooltips to true.

JdbNavToolBar properties

alignment

 public int getAlignment()
 public void setAlignment(int alignment)
Returns and sets the (FlowLayout) alignment for this JdbNavToolBar. The default layout/alignment for a JdbNavToolBar is FlowLayout with CENTER alignment. If the layout has been explicitly changed to be some layout other than FlowLayout, however, the value returned here is meaningless and always 0 and setting this property has no effect.

autoDetect

 public boolean isAutoDetect()
 public void setAutoDetect(boolean autoDetect)
Returns and sets whether JdbNavToolBar automatically attaches itself to DataSets within its enclosing highest-level container (usually a JFrame). Auto-detection occurs when the JdbNavToolBar is realized. Setting autoDetect to false after the component is realized sets the currently defined array of data-aware components to those specified by the dataSetAwareComponents property. Setting autoDetect to true, clears the dataSetAwareComponents and the dataSet property values.

buttonStateCancel

 public int getButtonStateCancel()
 public void setButtonStateCancel(int buttonStateCancel)
Returns and sets the state of the Cancel button. buttonStateCancel must be one of these values:

AUTO_ENABLED is the default state.

This is not a bound property and does not fire a property change event.

buttonStateDelete

 public int getButtonStateDelete()
 public void setButtonStateDelete(int buttonStateDelete)
Returns and sets the state of the Delete button. buttonStateDelete must be one of these values:

AUTO_ENABLED is the default state.

This is not a bound property and does not fire a property change event.

buttonStateDitto

 public int getButtonStateDitto()
 public void setButtonStateDitto(int buttonStateDitto)
Returns and sets the state of the Ditto button. buttonStateDitto must be one of these values:

AUTO_ENABLED is the default state.

This is not a bound property and does not fire a property change event.

buttonStateFirst

 public int getButtonStateFirst()
 public void setButtonStateFirst(int buttonStateFirst)
Returns and sets the state of the First button. buttonStateFirst must be one of these values:

AUTO_ENABLED is the default state.

This is not a bound property and does not fire a property change event.

buttonStateInsert

 public int getButtonStateInsert()
 public void setButtonStateInsert(int buttonStateInsert)
Returns and sets the state of the Insert button. buttonStateInsert must be one of these values:

AUTO_ENABLED is the default state.

This is not a bound property and does not fire a property change event.

buttonStateLast

 public int getButtonStateLast()
 public void setButtonStateLast(int buttonStateLast)
Returns and sets the state of the Last button. buttonStateLast must be one of these values:

AUTO_ENABLED is the default state.

This is not a bound property and does not fire a property change event.

buttonStateNext

 public int getButtonStateNext()
 public void setButtonStateNext(int buttonStateNext)
Returns and sets the state of the Next button. buttonStateNext must be one of these values:

AUTO_ENABLED is the default state.

This is not a bound property and does not fire a property change event.

buttonStatePost

 public int getButtonStatePost()
 public void setButtonStatePost(int buttonStatePost)
Returns and sets the state of the Post button. buttonStatePost must be one of these values:

AUTO_ENABLED is the default state.

This is not a bound property and does not fire a property change event.

buttonStatePrior

 public int getButtonStatePrior()
 public void setButtonStatePrior(int buttonStatePrior)
Returns and sets the state of the Prior button. buttonStatePrior must be one of these values:

AUTO_ENABLED is the default state.

This is not a bound property and does not fire a property change event.

buttonStateRefresh

 public int getButtonStateRefresh()
 public void setButtonStateRefresh(int buttonStateRefresh)
Returns and sets the state of the Refresh button. buttonStateRefresh must be one of these values:

AUTO_ENABLED is the default state.

This is not a bound property and does not fire a property change event.

buttonStateSave

 public int getButtonStateSave()
 public void setButtonStateSave(int buttonStateSave)
Returns and sets the state of the Save button. buttonStateSave must be one of these values:

AUTO_ENABLED is the default state.

This is not a bound property and does not fire a property change event.

cancelButton

 public JButton getCancelButton()
Returns a reference to the Cancel toolbar button (JButton).

dataSet

 public DataSet getDataSet()
 public void setDataSet(DataSet dataSet)
Returns and sets the DataSet whose data is navigated by this component. Setting this property to a non-null value disables the autoDetect property, and conversely, specifying a null value automatically enables the autoDetect property. When both the dataSet and dataSetAwareComponents properties are set, the one set most recently is the one that takes precedence and the setting of the other one is cleared.

See also: autoDetect

dataSetAwareComponents

 public Component[] getDataSetAwareComponents()
 public void setDataSetAwareComponents(Component[] dataAwareComponents)
Returns and sets the list of data-aware components to which JdbNavToolBar attaches itself. Setting this property to a non-null value disables the autoDetect property, and conversely, specifying a null value automatically enables the autoDetect property. When both the dataSet and dataSetAwareComponents properties are set, the one set most recently is the one that takes precedence and the setting of the other one is cleared.

See also: autoDetect

deleteButton

 public JButton getDeleteButton()
Returns a reference to the Delete toolbar button (JButton).

dittoButton

 public JButton getDittoButton()
Returns a reference to Ditto toolbar button (JButton).

firstButton

 public JButton getFirstButton()
Returns a reference to First toolbar button (JButton).

focusedDataSet

 public DataSet getFocusedDataSet()
 public void setFocusedDataSet(DataSet dataSet)
Returns and sets the current DataSet attached to JdbNavToolBar. This property can be used to specify the initial DataSet to which JdbNavToolBar should be attached.

This is a bound property and fires a property change event.

insertButton

 public JButton getInsertButton()
Returns a reference to Insert toolbar button (JButton).

lastButton

 public JButton getLastButton()
Returns a reference to Last toolbar button (JButton).

nextButton

 public JButton getNextButton()
Returns a reference to Next toolbar button (JButton).

orientation

 public int getOrientation()
 public void setOrientation(int orientation)
Returns and sets the orientation of the JdbNavToolBar. Possible values are HORIZONTAL and VERTICAL.

postButton

 public JButton getPostButton()
Returns a reference to Post toolbar button (JButton).

priorButton

 public JButton getPriorButton()
Returns a reference to Prior toolbar button (JButton).

refreshButton

 public JButton getRefreshButton()
Returns a reference to Refresh toolbar button (JButton).

saveButton

 public JButton getSaveButton()
Returns a reference to Save toolbar button (JButton).

showRollover

 public boolean isShowRollover()
 public void setShowRollover(boolean showRollover)
Determines whether a rollover icon is displayed when the mouse is moved over one of the toolbar buttons. The default value is true.

Note that rollover appearance is look-and-feel dependent. Specifically, JdbNavToolBar provides rollover icons for all look-and-feels other than Metal, which has its own built-in support for button rollover.

This is not a bound property and does not fire a property change event.

showTooltips

 public boolean isShowTooltips()
 public void setShowTooltips(boolean showTooltips)
Determines whether button tooltips are displayed. The default value is true.

This is not a bound property and does not fire a property change event.


JdbNavToolBar methods

addNotify()

  public void addNotify()

Overrides: com.sun.javax.swing.JComponent.addNotify()


JdbNavToolBar event listeners

This component is a source for the following event sets.

ancestor

 public void addAncestorListener(javax.swing.event.AncestorListener )
 public void removeAncestorListener(javax.swing.event.AncestorListener )

component

 public synchronized void addComponentListener(java.awt.event.ComponentListener )
 public synchronized void removeComponentListener(java.awt.event.ComponentListener )

container

 public synchronized void addContainerListener(java.awt.event.ContainerListener )
 public synchronized void removeContainerListener(java.awt.event.ContainerListener )

focus

 public synchronized void addFocusListener(java.awt.event.FocusListener )
 public synchronized void removeFocusListener(java.awt.event.FocusListener )

inputMethod

 public synchronized void addInputMethodListener(java.awt.event.InputMethodListener )
 public synchronized void removeInputMethodListener(java.awt.event.InputMethodListener )

key

 public synchronized void addKeyListener(java.awt.event.KeyListener )
 public synchronized void removeKeyListener(java.awt.event.KeyListener )

mouse

 public synchronized void addMouseListener(java.awt.event.MouseListener )
 public synchronized void removeMouseListener(java.awt.event.MouseListener )

mouseMotion

 public synchronized void addMouseMotionListener(java.awt.event.MouseMotionListener )
 public synchronized void removeMouseMotionListener(java.awt.event.MouseMotionListener )

propertyChange

 public synchronized void addPropertyChangeListener(java.beans.PropertyChangeListener )
 public synchronized void removePropertyChangeListener(java.beans.PropertyChangeListener )

vetoableChange

 public synchronized void addVetoableChangeListener(java.beans.VetoableChangeListener )
 public synchronized void removeVetoableChangeListener(java.beans.VetoableChangeListener )