The
itemStateChanged
event handler is a special user-defined
Function
that can be added to a component when it is created
and that will be called automatically with a single
ItemEvent
argument as described below.
An
itemStateChanged
event handler can only be added via
addEventHandler
after a component is created,
but an existing
itemStateChanged
event handler can be assigned new values.
Assigning
NULL
to
itemStateChanged
disables its functionality until a
non-NULL
value is assigned to it.
The
itemStateChanged
event handler is triggered in the following components under the
circumstances indicated:
| Canvas |
when the
state
field is changed, as when a mouse press or mouse release occurs
| | Checkbox |
when the checkbox is checked or unchecked by a mouse action
| | Choice |
when a choice box selection is made by a mouse action (the selected choice
does not need to change)
| | JButton |
when the
state
field is changed either by a mouse action or programmatically.
For a plain button, (i.e., not a checkbox or radiobutton),
the state can only be changed programmatically.
| | JCanvas |
when the
state
field is changed either by a mouse action or programmatically
| | JCheckBox |
when the
state
field is changed either by a mouse action or programmatically
| | JCheckBoxMenuItem |
when the
state
field is changed either by a mouse action or programmatically
| | JChoice |
see the entry for
JComboBox
| | JComboBox |
when the
selected
field is changed either by a mouse action or programmatically.
The handler is actually called twice for each change.
On the first call, the
ItemEvent's
state
field is zero and its
item
field contains the selected value prior to the change, while on the
second call,
state
is one and
item
is the newly selected value.
If the selection does not change, then the handler is not called.
| | JMenuItem |
when the
state
field is changed either by a mouse action or programmatically.
For a plain menu item (i.e., not a checkbox or radiobutton),
the state can only be changed programmatically.
| | JRadioButton |
when the
state
field is changed either by a mouse action or programmatically.
| | JRadioButtonMenuItem |
when the
state
field is changed either by a mouse action or programmatically.
| | JTextCanvas |
when the
state
field is changed either by a mouse action or programmatically.
|
Additionally, components that have a
popup
field for accommodating one of
PopupMenu
or
JPopupMenu
use an
itemStateChanged
event handler for checkbox or radiobutton menu item selection.
Similarly, components that have a
menubar
field also use the
itemStateChanged
event handler for checkbox or radiobutton menu item selection.
| |
| Return: |
none
| | |
| See Also: |
actionPerformed,
addEventHandler,
adjustmentValueChanged,
caretUpdate,
componentHidden,
componentMoved,
componentResized,
componentShown,
dragDropEnd,
dragEnter,
dragExit,
dragGestureRecognized,
dragMouseMoved,
dragOver,
drop,
dropActionChanged,
Event,
focusGained,
focusLost,
hyperlinkActivated,
hyperlinkEntered,
hyperlinkExited,
invocationAction,
invocationBrowse,
invocationChange,
invocationEdit,
invocationEditImport,
invocationEditKey,
invocationRun,
invocationSelection,
ItemEvent,
keyPressed,
keyReleased,
keyTyped,
mouseClicked,
mouseDragged,
mouseEntered,
mouseExited,
mouseMoved,
mousePressed,
mouseReleased,
mouseWheelMoved,
removeEventHandler,
stateChanged,
textValueChanged,
valueChanged,
windowActivated,
windowClosed,
windowClosing,
windowDeactivated,
windowDeiconified,
windowIconified,
windowOpened
|
|