Example usage for javax.swing KeyStroke equals

List of usage examples for javax.swing KeyStroke equals

Introduction

In this page you can find the example usage for javax.swing KeyStroke equals.

Prototype

public final boolean equals(Object anObject) 

Source Link

Document

Returns true if this object is identical to the specified object.

Usage

From source file:Main.java

public static void updateAccelerator(JMenuItem menuItem, KeyStroke oldAccelerator) {
    KeyStroke accelerator = menuItem.getAccelerator();
    if (oldAccelerator != null && oldAccelerator.equals(accelerator)) {
        return;/* ww w .j  ava  2s  . c  o m*/
    }

    InputMap map = menuItem.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    if (map != null && oldAccelerator != null) {
        map.remove(oldAccelerator);
    }
    if (accelerator != null) {
        if (map == null) {
            map = new ComponentInputMap(menuItem);
            menuItem.setInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW, map);
        }
        map.put(accelerator, "click");
    }
}