Java Swing AWT Question:

What is the function of Abstract Action class?

Tweet Share WhatsApp

Answer:

AbstractAction class allows the implementation of the abstract functions and the action interfaces. AbstractAction provides with the default functionality that are provided with the methods in the Action interface. The action can extend the class to create some specific actions for the users. The methods that is provided to implement the actionPerformed() method and it is used to provide the overall functionality for the action. ActionEvent is used to show the action command that can be used to add some features of the contents and provide ready to use action functionality on the event that can be carried for all the user interface fields.

class MyAction extends AbstractAction
{ }
public MyAction(String text, Icon icon)
{ super(text,icon); }
public void actionPerformed(ActionEvent e)
{ System.out.println("Action ["+e.getActionCommand()+"]!"); }

Download Swing AWT PDF Read All 29 Swing AWT Questions
Previous QuestionNext Question
What is the use of JComponent Class in Swing?What is the purpose of action interface in Swing?