|
Extension SDK 10.1.2 | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object oracle.ide.controls.ItemSelectableTracker
The ItemSelectableTracker
is a simple class for
tracking the state of an ItemSelectable
, such as a
JCheckBox
or JToggleButton
so that a
dependent group of Components
can be enabled or
disabled when the state of the ItemSelectable
changes.
For example, this is commonly used in UI settings panels with radio buttons when there are other components associated with one or more of the buttons that should be enabled when the associated radio button is enabled, and disabled when the associated radio button is disabled.
Two optional overrides, itemSelected()
and
itemDeselected()
are provided in case clients need to
do additional work besides enabling or disabling dependent
components.
Nested ItemSelectableTrackers can be used in cases where there are multiple levels of component dependencies. For example:
[X] Some top-level option (Component 1) [X] First-level child dependent (Component 2) [X] Second-level child dependent (Component 3)In these cases, it may be desirable to have an ItemSelectableTracker for the top-level option work with the ItemSelectableTracker for the second-level option. To do this, create an ItemSelectableTracker first for the relationship between component 2 and component 3. Then create an ItemSelectableTracker for component 1, and the other tracker.
Note that this class is intended only for a check box or button type of item. It is not intended for a list type of item, such as the AWT List, JComboBox, or JList.
Field Summary | |
protected java.awt.Component[] |
components
Stores the dependent components to enable when item is enabled. |
protected ItemSelectableTracker[] |
trackers
Stores the dependent trackers to enable when item is enabled. |
Constructor Summary | |
ItemSelectableTracker(java.awt.ItemSelectable selectableItem,
java.awt.Component[] dependentComponents)
Constructs a new ItemSelectableTracker to listen to
the state of specified item, and enable or disable the specified
dependent components based on that state. |
|
ItemSelectableTracker(java.awt.ItemSelectable selectableItem,
java.awt.Component[] dependentComponents,
boolean sameEnabledState)
Constructs a new ItemSelectableTracker to listen to
the state of specified item, and enable or disable the specified
dependent components based on that state. |
|
ItemSelectableTracker(java.awt.ItemSelectable selectableItem,
java.awt.Component[] dependentComponents,
ItemSelectableTracker[] dependentTrackers)
Construct a new ItemSelectableTracker to listen to
the state of the specified item, and manage a component that itself
has an ItemSelectableTracker registered. |
Method Summary | |
protected void |
itemDeselected(java.awt.ItemSelectable item)
This method may be overrided by subclasses to take care of any additional work when the given item is deselected. |
protected void |
itemSelected(java.awt.ItemSelectable item)
This method may be overrided by subclasses to take care of any additional work when the given item is selected. |
void |
itemStateChanged(java.awt.event.ItemEvent event)
Invoked when an item has been selected or deselected. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected java.awt.Component[] components
protected ItemSelectableTracker[] trackers
Constructor Detail |
public ItemSelectableTracker(java.awt.ItemSelectable selectableItem, java.awt.Component[] dependentComponents)
ItemSelectableTracker
to listen to
the state of specified item, and enable or disable the specified
dependent components based on that state. This will also update
the enabled/disabled state of the dependent components to help
initialize dependents correctly.
selectableItem
- the ItemSelectable
, such as
a JCheckBox
to trackdependentComponents
- an array of Components
to
enable when the specified item is enabled - this array is
assumed to be non-changingpublic ItemSelectableTracker(java.awt.ItemSelectable selectableItem, java.awt.Component[] dependentComponents, ItemSelectableTracker[] dependentTrackers)
ItemSelectableTracker
to listen to
the state of the specified item, and manage a component that itself
has an ItemSelectableTracker
registered. The enabled
state of the child selectable item of the subordinate tracker will
match the enabled state of the main selectable item. If a dependent component is itself an ItemSelectable, and you pass its tracker as on the the elements for dependentTrackers, you do not need to specify the component in the dependentComponents array.
selectableItem
- the ItemSelectable
, such as
a JCheckBox
to trackdependentComponents
- an array of Components
to
enable when the specified item is enabled - this array is
assumed to be non-changingdependentTrackers
- an array of dependent tracker relationships -
this array is assumed to be non-changing.public ItemSelectableTracker(java.awt.ItemSelectable selectableItem, java.awt.Component[] dependentComponents, boolean sameEnabledState)
ItemSelectableTracker
to listen to
the state of specified item, and enable or disable the specified
dependent components based on that state. This will also update
the enabled/disabled state of the dependent components to help
initialize dependents correctly.
selectableItem
- the ItemSelectable
, such as
a JCheckBox
to trackdependentComponents
- an array of Components
to
enable when the specified item is enabled - this array is
assumed to be non-changingsameEnabledState
- true
if the
dependentComponents
should have the same enabled state
as the selectableItem
. false
if the
state should reflect the opposite.Method Detail |
public final void itemStateChanged(java.awt.event.ItemEvent event)
itemStateChanged
in interface java.awt.event.ItemListener
event
- the ItemEvent objectprotected void itemSelected(java.awt.ItemSelectable item)
item
- the ItemSelectable
that was selectedprotected void itemDeselected(java.awt.ItemSelectable item)
item
- the ItemSelectable
that was deselected
|
Extension SDK | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright © 1997, 2004, Oracle. All rights reserved.