# Keyboard Binding

Other Swing Changes

> ## New Keyboard Binding Infrastructure

> The new keyboard binding infrastructure unifies and replaces the two previously existing schemes for binding user input (for example, Control-S) to program actions (for example, saving a file). The Swing Connection article Keyboard Bindings in Swing has details about the old and new keyboard binding schemes, including example code.

> The API changes for the new infrastructure center around two new classes -- ActionMap and InputMap. Other changes include new methods in JComponent, LookAndFeel, and SwingUtilities, as well as a few new special-purpose classes that descend from ActionMap and InputMap.

> See:

> `
> - javax.swing.ActionMap
> - javax.swing.InputMap
> - javax.swing.ComponentInputMap
> - javax.swing.plaf.ActionMapUIResource
> - javax.swing.plaf.InputMapUIResource
> - javax.swing.plaf.ComponentInputMapUIResource
> `

> New methods in JComponent:

> `
> - public ActionMap getActionMap()
> - public InputMap getInputMap()
> - public InputMap getInputMap(int condition)
> - public void setActionMap(ActionMap map)
> - public void setInputMap(int condition, InputMap map)
> `

> New methods in LookAndFeel:

> `
> - public static void loadKeyBindings(InputMap retMap, Object[] keys)
> - public static ComponentInputMap makeComponentInputMap(JComponent c, Object[] keys)
> - public static InputMap makeInputMap(Object[] keys)
> `

> New methods in SwingUtilities:

> `
> - public static InputMap getUIInputMap(JComponent component, int condition)
> - public static void replaceUIInputMap(JComponent component, int condition, InputMap map)
> - public static ActionMap getUIActionMap(JComponent component)
> - public static void replaceUIActionMap(JComponent component, ActionMap map)
> `

Copyright © 2000 Sun Microsystems, Inc. All Rights Reserved. Please send comments to: swing-feedback@java.sun.com. This is not a subscription list. | Java Software