Example usage for javax.swing KeyStroke isOnKeyRelease

List of usage examples for javax.swing KeyStroke isOnKeyRelease

Introduction

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

Prototype

public final boolean isOnKeyRelease() 

Source Link

Document

Returns whether this AWTKeyStroke represents a key release.

Usage

From source file:org.eclipse.wb.internal.swing.model.property.editor.accelerator.KeyStrokePropertyEditor.java

@Override
protected void openDialog(Property property) throws Exception {
    KeyStrokeDialog dialog = new KeyStrokeDialog(property.getTitle());
    // set initial KeyStroke
    {//from  w  w w . j  av a 2s.  co m
        Object value = property.getValue();
        if (value instanceof KeyStroke) {
            KeyStroke keyStroke = (KeyStroke) value;
            int modifiers = keyStroke.getModifiers();
            int keyCode = keyStroke.getKeyCode();
            boolean onKeyRelease = keyStroke.isOnKeyRelease();
            dialog.setKeyStroke(KeyStroke.getKeyStroke(keyCode, modifiers, onKeyRelease));
        } else {
            dialog.setKeyStroke(KeyStroke.getKeyStroke(0, 0));
        }
    }
    // open dialog
    if (dialog.open() == Window.OK) {
        KeyStroke keyStroke = dialog.getKeyStroke();
        GenericProperty genericProperty = (GenericProperty) property;
        // prepare source
        String source = getKeyStrokeSource(keyStroke);
        // update source
        genericProperty.setExpression(source, Property.UNKNOWN_VALUE);
    }
}