action : Java Glossary

go to home page A words local find full screen, hide local find menu Google search web for more information on this topic jump to foot of page translate this page with Babelfish punctuation 0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z (all) ©1996-2009 Roedy Green, Canadian Mind Products
action
a method that is invoked when some specific type of event occurs, such as a mouse click or keystroke. It returns true if it was able to completely handle the event. If it cannot handle the event, it may invoke super.action to see if the superclass method can deal with it. If that too fails it can return false to indirectly request that the event object be given to the parent object’s handleEvent method to deal with it. Normally an action method will return false. Unless it returns false, the event percolation will stop dead, and the event will not return back to the native GUI via the original peer object.

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?

Why not use Actions?

Learning More

Sun’s Javadoc on Action interface : available:


CMP homejump to top You can get the freshest copy of this page from: or possibly from your local J: drive (Java virtual drive/mindprod.com website mirror)
http://mindprod.com/jgloss/action.html J:\mindprod\jgloss\action.html
CMP logofeedback Please email your feedback for publication, errors, omissions, typos, formatting errors, ambiguities, unclear wording, broken/redirected link reports, suggestions to improve this page or comments to Roedy Green : feedback email
mindprod.com IP:[65.110.21.43]
view BlogYour face IP:[38.107.191.101]
You are visitor number 12,652.