List of usage examples for javax.swing KeyStroke getKeyStroke
public static KeyStroke getKeyStroke(int keyCode, int modifiers, boolean onKeyRelease)
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 ww . j a v a 2 s. c o 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); } }