The AbstractAction Class
The AbstractAction class is an abstract implementation of the Action interface. AbstractAction provides the default functionality for almost all methods in the Action interface. You can extend this class to create your own specific actions. If you do so, the only method for which you must provide an implementation is the actionPerformed( ) method, which provides the functionality for the action. Here is a simple example:
class MyAction extends AbstractAction { public MyAction(String text, Icon icon) { super(text,icon); } public void actionPerformed(ActionEvent e) { System.out.println("Action [" + e.getActionCommand( ) + "]!"); } }
Here, we simply print the action command sent with the ActionEvent. You can add more features based on the contents of the ActionEvent.