borland Packages Class Hierarchy dbswing Package
java.lang.Object +----java.awt.Component +----java.awt.Container +----javax.swing.JComponent +----javax.swing.JToolBar +----com.borland.dbswing.JdbNavToolBar
Variables Constructors Properties Methods Event Listeners
Implements AccessListener, NavigationListener, StatusListener, ActionListener, FocusListener, MouseListener, ImageObserver, MenuContainer, Serializable, EventListener, Accessible, ChangeListener, SwingConstants
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:
JdbNavToolBar
as a visual component in a frame. By default, JdbNavToolBar
automatically detects other data-aware components in the same root container (such as JFrame
), and navigates the DataSet
of the component that currently has focus. This behavior is controlled by the autoDetect
property.
Note that autoDetect
doesn't detect components added after JdbNavToolBar
has been realized. If your application adds data-aware components dynamically, and you want JdbNavToolBar
to navigate the DataSet
s of those newly added components, you must set autoDetect
to true
after adding a new component to your container.
Explicitly set the dataSet
property of JdbNavToolBar
, associating it with a single DataSet
.
Pass to the dataAwareComponents
property an array of data-aware components whose DataSets
are to be navigated. This is useful if your application dynamically adds and removes components from containers at runtime. The dataSetAwareComponents
property is visible in the Inspector only if you select the hidden level from the Inspector's context menu (right click a property in the Inspector to display the menu).
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
.
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
.
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.
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.
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.
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 DataSet
s.
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
.
public static final int AUTO_ENABLED = 0A
buttonState
property constant specifying that the button should be visible and automatically enabled/disabled.
public static final int AUTO_HIDDEN = 1A
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
.
public static final int DISABLED = 3A
buttonState
property constant specifying that the button should always be disabled.
public static final int ENABLED = 2A
buttonState
property constant specifying that the button should always be enabled.
public static final int HIDDEN = 4A
buttonState
property constant specifying that the button should always be hidden.
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
.
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.
public boolean isAutoDetect() public void setAutoDetect(boolean autoDetect)Returns and sets whether
JdbNavToolBar
automatically attaches itself to DataSet
s 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.
public int getButtonStateCancel() public void setButtonStateCancel(int buttonStateCancel)Returns and sets the state of the Cancel button.
buttonStateCancel
must be one of these values:
DataSet
. DataSet
. AUTO_ENABLED is the default state.
This is not a bound property and does not fire a property change event.
public int getButtonStateDelete() public void setButtonStateDelete(int buttonStateDelete)Returns and sets the state of the Delete button.
buttonStateDelete
must be one of these values:
DataSet
. DataSet
. AUTO_ENABLED is the default state.
This is not a bound property and does not fire a property change event.
public int getButtonStateDitto() public void setButtonStateDitto(int buttonStateDitto)Returns and sets the state of the Ditto button.
buttonStateDitto
must be one of these values:
DataSet
. DataSet
. AUTO_ENABLED is the default state.
This is not a bound property and does not fire a property change event.
public int getButtonStateFirst() public void setButtonStateFirst(int buttonStateFirst)Returns and sets the state of the First button.
buttonStateFirst
must be one of these values:
DataSet
. DataSet
. AUTO_ENABLED is the default state.
This is not a bound property and does not fire a property change event.
public int getButtonStateInsert() public void setButtonStateInsert(int buttonStateInsert)Returns and sets the state of the Insert button.
buttonStateInsert
must be one of these values:
DataSet
. DataSet
. AUTO_ENABLED is the default state.
This is not a bound property and does not fire a property change event.
public int getButtonStateLast() public void setButtonStateLast(int buttonStateLast)Returns and sets the state of the Last button.
buttonStateLast
must be one of these values:
DataSet
. DataSet
. AUTO_ENABLED is the default state.
This is not a bound property and does not fire a property change event.
public int getButtonStateNext() public void setButtonStateNext(int buttonStateNext)Returns and sets the state of the Next button.
buttonStateNext
must be one of these values:
DataSet
. DataSet
. AUTO_ENABLED is the default state.
This is not a bound property and does not fire a property change event.
public int getButtonStatePost() public void setButtonStatePost(int buttonStatePost)Returns and sets the state of the Post button.
buttonStatePost
must be one of these values:
DataSet
. DataSet
. AUTO_ENABLED is the default state.
This is not a bound property and does not fire a property change event.
public int getButtonStatePrior() public void setButtonStatePrior(int buttonStatePrior)Returns and sets the state of the Prior button.
buttonStatePrior
must be one of these values:
DataSet
. DataSet
. AUTO_ENABLED is the default state.
This is not a bound property and does not fire a property change event.
public int getButtonStateRefresh() public void setButtonStateRefresh(int buttonStateRefresh)Returns and sets the state of the Refresh button.
buttonStateRefresh
must be one of these values:
DataSet
. DataSet
. AUTO_ENABLED is the default state.
This is not a bound property and does not fire a property change event.
public int getButtonStateSave() public void setButtonStateSave(int buttonStateSave)Returns and sets the state of the Save button.
buttonStateSave
must be one of these values:
DataSet
. DataSet
. AUTO_ENABLED is the default state.
This is not a bound property and does not fire a property change event.
public JButton getCancelButton()Returns a reference to the Cancel toolbar button (
JButton
).
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.
autoDetect
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.
autoDetect
public JButton getDeleteButton()Returns a reference to the Delete toolbar button (
JButton
).
public JButton getDittoButton()Returns a reference to Ditto toolbar button (
JButton
).
public JButton getFirstButton()Returns a reference to First toolbar button (
JButton
).
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.
public JButton getInsertButton()Returns a reference to Insert toolbar button (
JButton
).
public JButton getLastButton()Returns a reference to Last toolbar button (
JButton
).
public JButton getNextButton()Returns a reference to Next toolbar button (
JButton
).
public int getOrientation() public void setOrientation(int orientation)Returns and sets the orientation of the
JdbNavToolBar
. Possible values are HORIZONTAL and VERTICAL.
public JButton getPostButton()Returns a reference to Post toolbar button (
JButton
).
public JButton getPriorButton()Returns a reference to Prior toolbar button (
JButton
).
public JButton getRefreshButton()Returns a reference to Refresh toolbar button (
JButton
).
public JButton getSaveButton()Returns a reference to Save toolbar button (
JButton
).
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.
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.
public void addNotify()
public void addAncestorListener(javax.swing.event.AncestorListener ) public void removeAncestorListener(javax.swing.event.AncestorListener )
public synchronized void addComponentListener(java.awt.event.ComponentListener ) public synchronized void removeComponentListener(java.awt.event.ComponentListener )
public synchronized void addContainerListener(java.awt.event.ContainerListener ) public synchronized void removeContainerListener(java.awt.event.ContainerListener )
public synchronized void addFocusListener(java.awt.event.FocusListener ) public synchronized void removeFocusListener(java.awt.event.FocusListener )
public synchronized void addInputMethodListener(java.awt.event.InputMethodListener ) public synchronized void removeInputMethodListener(java.awt.event.InputMethodListener )
public synchronized void addKeyListener(java.awt.event.KeyListener ) public synchronized void removeKeyListener(java.awt.event.KeyListener )
public synchronized void addMouseListener(java.awt.event.MouseListener ) public synchronized void removeMouseListener(java.awt.event.MouseListener )
public synchronized void addMouseMotionListener(java.awt.event.MouseMotionListener ) public synchronized void removeMouseMotionListener(java.awt.event.MouseMotionListener )
public synchronized void addPropertyChangeListener(java.beans.PropertyChangeListener ) public synchronized void removePropertyChangeListener(java.beans.PropertyChangeListener )
public synchronized void addVetoableChangeListener(java.beans.VetoableChangeListener ) public synchronized void removeVetoableChangeListener(java.beans.VetoableChangeListener )