Why do we have to use the extra object ActionMap?
What’s the meaning?
Take this as an example:
imap.put(KeyStroke.getKeyStroke("ctrl Y"), "panel.yellow");
ActionMap amap = panel.getActionMap();
amap.put("panel.yellow", yellowAction);
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
As shown in this example, an
InputMapassociates aKeyStrokewith an abstract name that identifies the correspodingAction. TheActionMapuses that name as a key to evoke a particularActioninstance’sactionPerformed()method. As a concrete example, thisScrollTimeruses theActionMapof aJScrollPaneto look up actions by name and use them without direct access to the implementation.Addendum: The abstraction was designed to support the “pluggable look and feel” (L&F) architecture describe here.