The Action interface in Swing is a glorified ActionListener. You typically extend AbstractAction and attach it to a JMenuItem to field its ActionEvents. You can use that same same Action to field ActionEvents from JButtons. If you do an Action.setEnabled( false ), that disables all the attached widgets in sync. The actionPerformed method of an individual Action can use getActionCommand to do a Hashtable lookup to find the code to execute. Alternatively, you can use the first character of the actionCommand as a case index. Alternatively, you can embed a binary 16-bit unsigned integer as the first character of an actionCommand and use that as an array index. Typically you use one Action per JMenuItem and redirect all (possibly predigested) ActionEvents to a common ActionListener for dispatching.
Why use Actions?
action.putValue( "ToolTipText", "Fermez le fichier" );
This page is posted |
http://mindprod.com/jgloss/action.html | |
Optional Replicator mirror
|
J:\mindprod\jgloss\action.html | |
Please read the feedback from other visitors,
or send your own feedback about the site. Contact Roedy. Please feel free to link to this page without explicit permission. | ||
Canadian
Mind
Products
IP:[65.110.21.43] Your face IP:[3.135.247.24] |
| |
Feedback |
You are visitor number | |