JavaSwingComponentsActions: ActionEvent sources and ActionListeners


ActionEvent sources and ActionListeners

Action event sources and their action commands

(no heavyweight AWT components)

Source

Action command

Timer

null (undocumented)

JTextField

set value (but no get, default is probably null), or text (iff value is null),

AbstractButton

set/get to from model (implicitly done from action) - but taken from model's event, or text (iff value is null)

ButtonModel

set/get: default unknown

JFileChooser

APPROVE_SELECTION="ApproveSelection", CANCEL_SELECTION="CancelSelection"

ComboBoxEditor

unspecified (probably unimportant, ChangeListener should have been used instead anyway)

BasicComboBoxEditor

delegates to text field (that means it is the current text)

JComboBox

set/get: default "comboBoxChanged" (documented?)

1.4: when event forwarded from editor: "comboBoxEdited"

(what good is implementing such logic if it isn't documented?)

Some places (BasicComboBoxUI, DefaultCellEditor for JComboBox, more?) also invoke JComboBox's actionPerformed by hand (they use "" as action command).

Use of action commands by ActionListeners

Class

Use

Classification

BasicMenuItemUI

compares the menuItem's action command (not an event's) (with ==) to a fixed set of strings, if none of them, plays sound

(in order not to play when the menu item is part of a internal frame "system menu".)

hack, will give false positives

MotifInternalFrameTitlePane

uses the same ActionListener for multiple buttons/menu items

OK (internal)

Uses of ActionListener

Class

Description

Autoscroller

uses Timer

AbstractButton

forwards ActionEvents from model

JComboBox

forwards (with setSelectedItem logic) ActionEvents from editor

JViewport

uses Timer for repainting later

ToolTipManager

uses Timer for displaying/hiding etc. tooltip

DefaultCellEditor

stop editing (text field, combo box, check box)

DefaultTreeCellEditor

uses Timer for maybe starting editing later

BasicComboBoxEditor

DefaultCaret

uses Timer for blinking

html/FormView

submit data (or focus change, or reset)

show file chooser (for file input fields)

html/IsIndexView

follow URL

JColorChooser

DefaultHSBChooserPanel

ok, cancel, internal listeners

java.awt.dnd.DropTarget

uses Timer for auto scrolling

Uses of ActionListener in the LAF classes

Class

Description

BasicDropTargetListener

uses Timer for auto scrolling

BasicComboBoxUI

hack to avoid swallowing enter (won't work if executed after combo box's, in fact break) (ActionListener on editor)

BasicComboPopup

uses Timers for auto scrolling

BasicProgressBarUI

uses Timer for animation (indeterminate)

BasicScrollBarUI

uses Timer for auto scrolling

BasicSliderUI

uses Timer for auto scrolling

BasicSplitPaneDivider

one-touch-expandable button action listeners

BasicSplitPaneUI

a lot of unused remains (now actions)

BasicTreeUI

uses TImer/ComponentListener to possibly invalidate the tree

MetalDesktopIconUI

on button (reshow frame)

MotifDesktopIconUI

on button (show system menu)

MotifInternalFrameTitlePane

on menu items, on button (show system menu)

BasicOptionPaneUI

on text field -> transfer to input value

on buttons -> transfer to value

MetalFileChooserUI

on combo box (set as directory)

on mode buttons

on text field (editor???)

WindowsFileChooserUI

like Metal; on shortcut panel buttons

Uses of Actions as ActionListeners

(i.e. given to a Timer or an addActionListener method)

Class

Description

BasicMenuUI

for Timer (defer showing popup)

BasicInternalFrameTitlePane

iconify, maximize, close buttons

BasicSpinnerUI

action listeners on buttons, also used for Timer (auto-repeat)

MetalFileChooserUI

WindowsFileChooserUI

buttons: getGoHomeAction, getApproveSelectionAction, getCancelSelectionAction

MotifFileChooserUI

buttons: getUpdateAction, getApproveSelectionAction, getCancelSelectionAction


(C) 2001-2009 Christian Kaufhold (swing@chka.de)