List of usage examples for javax.swing KeyStroke getKeyStroke
public static KeyStroke getKeyStroke(String s)
KeyStroke
. From source file:org.colombbus.tangara.EditorFrame.java
/** * Returns the paste action/*from w ww . ja va2s.co m*/ * * @return */ public Action getPasteAction() { if (pasteAction == null) { pasteAction = new AbstractAction(Messages.getString("Banner.menu.paste")) { //$NON-NLS-1$ @Override public void actionPerformed(ActionEvent e) { paste(); } }; pasteAction.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke("control V")); } return pasteAction; }
From source file:org.colombbus.tangara.EditorFrame.java
/** * Returns the undo action//from w ww .j av a2s .c o m * * @return */ public Action getUndoAction() { if (undoAction == null) { undoAction = new AbstractAction(Messages.getString("Banner.menu.undo")) { //$NON-NLS-1$ @Override public void actionPerformed(ActionEvent e) { programUndo(); } }; undoAction.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke("control Z")); } return undoAction; }
From source file:org.colombbus.tangara.EditorFrame.java
/** * Returns the undo action/* ww w . j a v a 2s . c o m*/ * * @return */ public Action getRedoAction() { if (redoAction == null) { redoAction = new AbstractAction(Messages.getString("Banner.menu.redo")) { //$NON-NLS-1$ @Override public void actionPerformed(ActionEvent e) { programRedo(); } }; redoAction.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke("control Y")); } return redoAction; }
From source file:org.datavyu.views.DatavyuView.java
/** * Constructor./*w w w . j av a 2s. c o m*/ * * @param app * The SingleFrameApplication that invoked this main FrameView. */ public DatavyuView(final SingleFrameApplication app) { super(app); KeyboardFocusManager manager = KeyboardFocusManager.getCurrentKeyboardFocusManager(); manager.addKeyEventDispatcher(new KeyEventDispatcher() { /** * Dispatches the keystroke to the correct action. * * @param evt The event that triggered this action. * @return true if the KeyboardFocusManager should take no further * action with regard to the KeyEvent; false otherwise. */ @Override public boolean dispatchKeyEvent(final KeyEvent evt) { // Pass the keyevent onto the keyswitchboard so that it can // route it to the correct action. // spreadsheetMenuSelected(null); return Datavyu.getApplication().dispatchKeyEvent(evt); } }); // generated GUI builder code initComponents(); // BugzID:492 - Set the shortcut for new cell, so a keystroke that won't // get confused for the "carriage return". The shortcut for new cells // is handled in Datavyu.java newCellMenuItem.setAccelerator(KeyStroke.getKeyStroke('\u21A9')); // BugzID:521 + 468 - Define accelerator keys based on Operating system. int keyMask = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(); weakTemporalOrderMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_T, keyMask)); strongTemporalOrderMenuItem .setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_T, InputEvent.SHIFT_MASK | keyMask)); // Set zoom in to keyMask + '+' zoomInMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_PLUS, keyMask)); // Set zoom out to keyMask + '-' zoomOutMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_MINUS, keyMask)); // Set reset zoom to keyMask + '0' resetZoomMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_0, keyMask)); // Set the save accelerator to keyMask + 'S' saveMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, keyMask)); // Set the save as accelerator to keyMask + shift + 'S' saveAsMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, keyMask | InputEvent.SHIFT_MASK)); // Set the open accelerator to keyMask + 'o'; openMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, keyMask)); // Set the new accelerator to keyMask + 'N'; newMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, keyMask)); // Set the new accelerator to keyMask + 'L'; newCellLeftMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_L, keyMask)); // Set the new accelerator to keyMask + 'R'; newCellRightMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_R, keyMask)); // Set the show spreadsheet accelrator to F5. showSpreadsheetMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F5, 0)); // Set the undo accelerator to keyMask + 'Z'; undoSpreadSheetMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Z, keyMask)); // Set the redo accelerator to keyMask + 'Y' redoSpreadSheetMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Y, keyMask)); if (panel != null) { panel.deregisterListeners(); panel.removeFileDropEventListener(this); } panel = new SpreadsheetPanel(Datavyu.getProjectController().getDB(), null); panel.registerListeners(); panel.addFileDropEventListener(this); setComponent(panel); System.out.println(getComponent()); // initialize the undo/redo system spreadsheetUndoManager = new SpreadsheetUndoManager(); undoSupport = new UndoableEditSupport(); undoSupport.addUndoableEditListener(new UndoAdapter()); refreshUndoRedo(); ////// //Jakrabbit Menu pushMenuItem.setVisible(false); pullMenuItem.setVisible(false); jSeparator10.setVisible(false); }
From source file:org.eclipse.jubula.rc.common.driver.KeyTyper.java
/** * Types the given keystroke. The arguments must adhere to the specification * at <a//from ww w . j a v a 2s . c om * href=http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/KeyStroke.html#getKeyStroke(java.lang.String)> * If any of the intercepting and event matching arguments are * <code>null</code>, this method will not wait for event confirmation. It * will simply assume that the events were received correctly. Otherwise, * this method will use the given interceptor and event matcher arguments to * handle event confirmation. * * @param keyStrokeSpec The key code. * @param interceptor The interceptor that will be used to wait for event * confirmation. * @param keyDownMatcher The event matcher to be used for key press event * confirmation. * @param keyUpMatcher The event matcher to be used for key release event * confirmation. */ public void type(String keyStrokeSpec, IRobotEventInterceptor interceptor, IEventMatcher keyDownMatcher, IEventMatcher keyUpMatcher) { KeyStroke keyStroke = KeyStroke.getKeyStroke(keyStrokeSpec); if (keyStroke == null) { String trimmedKeyStrokeSpec = keyStrokeSpec.trim(); int indexOfKeySpec = trimmedKeyStrokeSpec.lastIndexOf(" "); //$NON-NLS-1$ if (indexOfKeySpec != -1) { String keySpec = trimmedKeyStrokeSpec.substring(indexOfKeySpec + 1, trimmedKeyStrokeSpec.length()); KeyStroke checkKeyStroke = KeyStroke.getKeyStroke(keySpec); if (checkKeyStroke == null) { throw new StepExecutionException("invalid key spec", //$NON-NLS-1$ EventFactory.createActionError("TestErrorEvent.InvalidKeySpec", //$NON-NLS-1$ new String[] { keySpec })); } String invalidModifier = trimmedKeyStrokeSpec.substring(0, indexOfKeySpec).trim(); throw new StepExecutionException("invalid modifier", //$NON-NLS-1$ EventFactory.createActionError("TestErrorEvent.InvalidModifier", //$NON-NLS-1$ new String[] { invalidModifier })); } } type(keyStroke, interceptor, keyDownMatcher, keyUpMatcher); }
From source file:org.eclipse.jubula.rc.swt.driver.RobotSwtImpl.java
/** * Creates a KeyStroke of the given keyStrokeSpec * //w w w .j a v a 2 s . com * @param keyStrokeSpec * see {@link KeyStroke#getKeyStroke(String)} and * {@link KeyStroke#getKeyStroke(Char)} * @return a KeyStroke. * @throws RobotException * if no KeyStroke can be created. */ private KeyStroke getKeyStroke(String keyStrokeSpec) throws RobotException { KeyStroke keyStroke; if (keyStrokeSpec.length() == 1) { char singeKeyStrokeSpecChar = keyStrokeSpec.charAt(0); singeKeyStrokeSpecChar = getOSSspecificSpecBaseCharacter(singeKeyStrokeSpecChar); keyStroke = KeyStroke.getKeyStroke(singeKeyStrokeSpecChar); } else { int keyStrokeSpecSize = keyStrokeSpec.length(); char keySpec = keyStrokeSpec.charAt(keyStrokeSpecSize - 1); // ''.toUpperCase is "SS" we do not want that! if ('' != keySpec) { keySpec = Character.toUpperCase(keySpec); } String modifiedKeyStrokeSpec = keyStrokeSpec.substring(0, keyStrokeSpecSize - 1) + keySpec; keyStroke = KeyStroke.getKeyStroke(modifiedKeyStrokeSpec); } if (keyStroke == null) { final String msg = "Failed to post keystroke '" + keyStrokeSpec //$NON-NLS-1$ + "'"; //$NON-NLS-1$ if (log.isWarnEnabled()) { log.warn(msg); } throw new RobotException(msg, EventFactory.createActionError(TestErrorEvent.INVALID_PARAM_VALUE)); } return keyStroke; }
From source file:org.eurocarbdb.application.glycoworkbench.plugin.s3.gui.SignedGetUrlDialog.java
public SignedGetUrlDialog(Frame ownerFrame, HyperlinkActivatedListener hyperlinkListener, S3Service s3Service, S3Object[] objects) {// w w w .ja v a 2 s . com super(ownerFrame, "Generate Signed GET URLs", true); this.ownerFrame = ownerFrame; this.hyperlinkListener = hyperlinkListener; this.s3Service = s3Service; this.objects = objects; String introductionText = "<html><center>Generate signed GET URLs that you can provide to anyone<br>" + "who needs to access objects in your bucket for a limited time.</center></html>"; JHtmlLabel introductionLabel = new JHtmlLabel(introductionText, hyperlinkListener); introductionLabel.setHorizontalAlignment(JLabel.CENTER); JHtmlLabel expiryTimeLabel = new JHtmlLabel("<html><b>Expiry Time</b> (Hours)</html>", hyperlinkListener); expiryTimeLabel.setHorizontalAlignment(JLabel.RIGHT); JHtmlLabel httpsUrlsLabel = new JHtmlLabel("<html><b>Secure HTTPS URLs?</b></html>", hyperlinkListener); httpsUrlsLabel.setHorizontalAlignment(JLabel.RIGHT); JHtmlLabel virtualHostLabel = new JHtmlLabel("<html><b>Bucket is a Virtual Host?</b></html>", hyperlinkListener); virtualHostLabel.setHorizontalAlignment(JLabel.RIGHT); JHtmlLabel requesterPaysLabel = new JHtmlLabel("<html><b>Bucket is Requester Pays?</b></html>", hyperlinkListener); requesterPaysLabel.setHorizontalAlignment(JLabel.RIGHT); expiryTimeTextField = new JTextField("1.0"); expiryTimeTextField.setToolTipText("How long in hours until the URL will expire"); expiryTimeTextField.getDocument().addDocumentListener(this); httpsUrlsCheckBox = new JCheckBox(); httpsUrlsCheckBox.setSelected(false); httpsUrlsCheckBox.setToolTipText("Check this box to generate secure HTTPS URLs."); httpsUrlsCheckBox.addActionListener(this); virtualHostCheckBox = new JCheckBox(); virtualHostCheckBox.setSelected(false); virtualHostCheckBox.setToolTipText("Check this box if your bucket is configured as a virtual host."); virtualHostCheckBox.addActionListener(this); requesterPaysCheckBox = new JCheckBox(); requesterPaysCheckBox.setSelected(false); requesterPaysCheckBox.setToolTipText("Check this box if the bucket has Requester Pays enabled."); requesterPaysCheckBox.addActionListener(this); finishedButton = new JButton("Finished"); finishedButton.setActionCommand("Finished"); finishedButton.addActionListener(this); signedUrlsTextArea = new JTextArea(); signedUrlsTextArea.setEditable(false); // Set default ENTER and ESCAPE buttons. this.getRootPane().setDefaultButton(finishedButton); this.getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("ESCAPE"), "ESCAPE"); this.getRootPane().getActionMap().put("ESCAPE", new AbstractAction() { private static final long serialVersionUID = -6225706489569112809L; public void actionPerformed(ActionEvent actionEvent) { setVisible(false); } }); JPanel panel = new JPanel(new GridBagLayout()); int row = 0; panel.add(introductionLabel, new GridBagConstraints(0, row, 6, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); panel.add(expiryTimeLabel, new GridBagConstraints(0, ++row, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); panel.add(expiryTimeTextField, new GridBagConstraints(1, row, 5, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); panel.add(httpsUrlsLabel, new GridBagConstraints(0, ++row, 1, 1, 0.3, 0, GridBagConstraints.EAST, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); panel.add(httpsUrlsCheckBox, new GridBagConstraints(1, row, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, insetsDefault, 0, 0)); panel.add(virtualHostLabel, new GridBagConstraints(2, row, 1, 1, 0.3, 0, GridBagConstraints.EAST, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); panel.add(virtualHostCheckBox, new GridBagConstraints(3, row, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, insetsDefault, 0, 0)); panel.add(requesterPaysLabel, new GridBagConstraints(4, row, 1, 1, 0.3, 0, GridBagConstraints.EAST, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); panel.add(requesterPaysCheckBox, new GridBagConstraints(5, row, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, insetsDefault, 0, 0)); panel.add(new JScrollPane(signedUrlsTextArea), new GridBagConstraints(0, ++row, 6, 1, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, insetsDefault, 0, 0)); panel.add(finishedButton, new GridBagConstraints(0, ++row, 6, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.NONE, insetsDefault, 0, 0)); this.getContentPane().setLayout(new GridBagLayout()); this.getContentPane().add(panel, new GridBagConstraints(0, 0, 1, 1, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, insetsDefault, 0, 0)); this.setSize(700, 450); this.setResizable(true); this.setLocationRelativeTo(ownerFrame); generateSignedUrls(); }