Action and AbstractAction
Java defi nes a subinterface of the ActionListener interface called Action. Among the methods that Action adds to ActionListener are
Object getValue(String key);void putValue(String key, Object value);
These two methods assume the existence of a maplike structure that uses strings to access objects. Java provides an abstract class called AbstractAction that implements the methods in Action, leaving only the
void actionPerformed(ActionEvent e)
method to be implemented by the programmer. Research the AbstractAction class online and then write a subclass of AbstractAction called ColorAction that maps names of colors to Color objects. Write a GUI program with a JTextfi eld in a panel and add the panel to a JFrame. JTextfi elds fi re Action events when a user types a string and presses the Enter key. Add an object of ColorAction as an ActionListener to the JTextfi eld to handle such Action events. Whenever the user enters the name of a color in the JTextfi eld, the ColorAction object should map the string in the JTextfi eld to a color and then use that color to set the background of the panel.
We need at least 10 more requests to produce the solution.
0 / 10 have requested this problem solution
The more requests, the faster the answer.