List of usage examples for java.awt.event KeyEvent getKeyCode
public int getKeyCode()
From source file:com.emental.mindraider.ui.dialogs.DownloadModelJDialog.java
/** * Constructor./*from ww w . j a v a 2 s. c o m*/ * * @param union * made union of models. */ public DownloadModelJDialog(boolean union) { super(Messages.getString("DownloadModelJDialog.title")); JPanel p = new JPanel(); p.setLayout(new FlowLayout(FlowLayout.CENTER, 1, 5)); p.add(new JLabel(Messages.getString("DownloadModelJDialog.url"))); String[] knowUris = new String[] { "http://", "http://wymiwyg.org/", "http://www.osar.ch", "http://wymiwyg.org/.rdf?appendLang=en&till=50", "http://www.osar.ch/.rdf?appendLang=de&till=50" }; modelUrlCombo = new JComboBox(knowUris); modelUrlCombo.setEditable(true); modelUrlCombo.addKeyListener(new KeyListener() { public void keyPressed(KeyEvent keyEvent) { if (keyEvent.getKeyCode() == KeyEvent.VK_ENTER) { upload(); } } public void keyReleased(KeyEvent keyEvent) { } public void keyTyped(KeyEvent keyEvent) { } }); p.add(modelUrlCombo); JButton uploadButton = new JButton(Messages.getString("DownloadModelJDialog.download")); uploadButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { upload(); } }); p.add(uploadButton); JButton cancelButton = new JButton(Messages.getString("DownloadModelJDialog.cancel")); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { dispose(); } }); p.add(cancelButton); getContentPane().add(p, BorderLayout.CENTER); // show pack(); Gfx.centerAndShowWindow(this); }
From source file:org.executequery.gui.ReadOnlyTextPanePopUpMenu.java
public ReadOnlyTextPanePopUpMenu(ReadOnlyTextPane readOnlyTextPane) { this.readOnlyTextArea = readOnlyTextPane; reflectiveAction = new ReflectiveAction(this); String[] menuLabels = { "Copy", "Select All", "Save to File", "Clear" }; String[] actionCommands = { "copy", "selectAll", "saveToFile", "clear" }; String[] toolTips = { "", "", "Save the contents to file", "Clear the output pane" }; for (int i = 0; i < menuLabels.length; i++) { add(createMenuItem(menuLabels[i], actionCommands[i], toolTips[i])); }/*from ww w. j av a2 s . co m*/ readOnlyTextPane.getTextComponent().addKeyListener(new KeyListener() { public void keyReleased(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_BACK_SPACE) { clear(null); } } public void keyTyped(KeyEvent e) { } public void keyPressed(KeyEvent e) { } }); }
From source file:com.haulmont.cuba.desktop.gui.components.DesktopFilterHelper.java
@Override public void addShortcutListener(TextField textField, final ShortcutListener listener) { final JTextField dTextField = (JTextField) DesktopComponentsHelper.unwrap(textField); final KeyStroke keyStroke = DesktopComponentsHelper.convertKeyCombination(listener.getKeyCombination()); dTextField.addKeyListener(new KeyAdapter() { @Override//from w w w . jav a 2 s.c o m public void keyReleased(KeyEvent e) { if (ObjectUtils.equals(e.getKeyCode(), keyStroke.getKeyCode()) && ObjectUtils.equals(e.getModifiers(), keyStroke.getModifiers())) { listener.handleShortcutPressed(); } } }); }
From source file:org.slage.ui.KeyHandler.java
/** * Check if the handler should be fired, firing if needed * /* www .j a v a 2s . co m*/ * @param keyEvt * key event * @return true if we fired */ public boolean fire(KeyEvent keyEvt) { if ((iKey == keyEvt.getKeyCode() || iKey == keyEvt.getKeyChar()) && bAlt == keyEvt.isAltDown() && bCtrl == keyEvt.isControlDown() && bShift == keyEvt.isShiftDown()) { handler.execute(); return true; } return false; }
From source file:org.ngrinder.recorder.ui.AboutDialog.java
private void initKeyStroke() { addKeyListener(new KeyAdapter() { @Override/*from ww w. jav a2s. c o m*/ public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { dispose(); } } }); JRootPane rootPane = getRootPane(); rootPane.getActionMap().put("ESCAPE", new AbstractAction() { private static final long serialVersionUID = 421791976774749694L; public void actionPerformed(ActionEvent e) { dispose(); } }); KeyStroke keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0, false); rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(keyStroke, "ESCAPE"); }
From source file:org.kalypso.ogc.gml.map.widgets.advanced.edit.AdvancedPolygonEditWidget.java
/** * Escape Key pressed? -> reset / deactivate widget * // ww w .j a v a 2 s . com * @see org.kalypso.ogc.gml.widgets.AbstractWidget#keyReleased(java.awt.event.KeyEvent) */ @Override public void keyReleased(final KeyEvent e) { final int keyCode = e.getKeyCode(); if (KeyEvent.VK_SPACE == keyCode) { switchMode(); } super.keyReleased(e); }
From source file:org.kalypso.model.wspm.ui.action.selection.AbstractProfilePointSelectionWidget.java
@Override public void keyReleased(final KeyEvent e) { final int keyCode = e.getKeyCode(); switch (keyCode) { case KeyEvent.VK_ESCAPE: finish();//from w w w.j a v a 2s. c o m break; } }
From source file:nz.govt.natlib.ndha.manualdeposit.dialogs.EnterEntityNameAndPrefix.java
private void txtEnterFilePrefixKeyPressed(java.awt.event.KeyEvent evt) { if (evt.getKeyCode() == KeyEvent.VK_ESCAPE) { cancel();// ww w . j a v a 2 s. c om } }
From source file:com.emental.mindraider.ui.dialogs.NewRdfModelJDialog.java
/** * Constructor.// ww w.j av a 2 s . c om */ public NewRdfModelJDialog() { super(Messages.getString("NewRdfModelJDialog.title")); JPanel framePanel = new JPanel(); framePanel.setLayout(new GridLayout(3, 1)); JPanel p = new JPanel(); p.setLayout(new FlowLayout(FlowLayout.RIGHT)); p.add(new JLabel(Messages.getString("NewRdfModelJDialog.subject"))); subjectNs = new JTextField(30); subjectNs.setText(MindRaiderConstants.MR_RDF_PREDICATE_NS); p.add(subjectNs); p.add(new JLabel("#")); subjectLocalName = new JTextField(15); p.add(subjectLocalName); framePanel.add(p); p = new JPanel(); p.setLayout(new FlowLayout(FlowLayout.RIGHT)); final JCheckBox literalCheckBox = new JCheckBox("literal", false); p.add(literalCheckBox); framePanel.add(p); p = new JPanel(); p.setLayout(new FlowLayout(FlowLayout.CENTER)); JButton addButton = new JButton(Messages.getString("NewRdfModelJDialog.create")); p.add(addButton); addButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { createModel(literalCheckBox); } }); JButton cancelButton = new JButton(Messages.getString("NewRdfModelJDialog.cancel")); p.add(cancelButton); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { NewRdfModelJDialog.this.dispose(); } }); framePanel.add(p); subjectLocalName.addKeyListener(new KeyListener() { public void keyPressed(KeyEvent keyEvent) { if (keyEvent.getKeyCode() == KeyEvent.VK_ENTER) { createModel(literalCheckBox); } } public void keyReleased(KeyEvent keyEvent) { } public void keyTyped(KeyEvent keyEvent) { } }); getContentPane().add(framePanel, BorderLayout.CENTER); // show pack(); Gfx.centerAndShowWindow(this); addWindowListener(new WindowAdapter() { public void windowActivated(WindowEvent e) { subjectLocalName.requestFocusInWindow(); } }); }
From source file:com.haulmont.cuba.desktop.sys.vcl.DatePicker.DatePicker.java
@Override public void setEditor(final JFormattedTextField editor) { final int ENTER_CODE = 10; editor.addKeyListener(new KeyAdapter() { @Override/*from www. jav a 2 s . com*/ public void keyTyped(KeyEvent e) { if (e.getKeyChar() == '\u007F' && editor.getCaretPosition() < format.length()) { editor.setCaretPosition(editor.getCaretPosition() + 1); } } @Override public void keyPressed(KeyEvent event) { if (ENTER_CODE == event.getKeyCode()) try { editor.commitEdit(); } catch (ParseException e) { // } } }); editor.addFocusListener(new FocusAdapter() { @Override public void focusLost(FocusEvent e) { editor.setCaretPosition(0); } }); super.setEditor(editor); if (format == null) { setFormats( Datatypes.getFormatStrings(AppBeans.get(UserSessionSource.class).getLocale()).getDateFormat()); } else setFormats(format); }