Package javax.swing

Examples of javax.swing.KeyStroke


            });

            getRootPane().setDefaultButton(closeButton);
            setResizable(false);
            setDefaultCloseOperation(JInternalFrame.DISPOSE_ON_CLOSE);
            KeyStroke ks = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
            getRootPane().registerKeyboardAction(closeAction, ks, JComponent.WHEN_IN_FOCUSED_WINDOW);
            //setPreferredSize(calculatePreferredDialogSize());
        }
View Full Code Here


        super.bind();
        searchField
                .addActionListener(getAction(JXDialog.EXECUTE_ACTION_COMMAND));
        findNext.setAction(getAction(FIND_NEXT_ACTION_COMMAND));
        findPrevious.setAction(getAction(FIND_PREVIOUS_ACTION_COMMAND));
        KeyStroke stroke = KeyStroke.getKeyStroke("ESCAPE");
        getInputMap(WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(stroke,
                JXDialog.CLOSE_ACTION_COMMAND);
    }
View Full Code Here

                return (cancelButton != null) && (cancelButton.isEnabled());
            }
        };
        getActionMap().put("esc-action", escAction);
        InputMap im = getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
        KeyStroke key = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
        im.put(key, "esc-action");
    }
View Full Code Here

                    item = new JMenuItem(((String) m[i]).substring(1));

                    char c = ((String) m[i]).charAt(0);

                    if (c != '-') {
                        KeyStroke key =
                            KeyStroke.getKeyStroke(c, Event.CTRL_MASK);

                        item.setAccelerator(key);
                    }
                } else {
View Full Code Here

    private void addCtrlAccel(int vk, String actionConstant, Action action) {
    RootPaneContainer root = (RootPaneContainer)container;
    InputMap inputMap = root.getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);

    KeyStroke key = KeyStroke.getKeyStroke(vk, InputEvent.CTRL_MASK);
    inputMap.put(key, actionConstant);
    if (action == null)
      action = menuManager.getActionFromId(actionConstant);
    root.getRootPane().getActionMap().put(actionConstant, action);
  }
View Full Code Here

        }
        if(check != null) {
            result.width += check.getIconWidth() + textIconGap;
            result.height = Math.max(result.height, check.getIconHeight());
        }
        final KeyStroke accelerator = item.getAccelerator();
        if (accelerator != null) {
            String accelText = Utilities.getAcceleratorText(accelerator,
                                                            acceleratorDelimiter);
            FontMetrics fm = item.getFontMetrics(acceleratorFont);
            result.width += fm.stringWidth(accelText) + 3*textIconGap;
 
View Full Code Here

        }
        return arrowInset;
    }

    private void paintAccelerator(final Graphics g, final Rectangle viewR, final Rectangle iconR, final Rectangle textR, final int textIconGap, final boolean isLTR) {
        final KeyStroke accel = menuItem.getAccelerator();
        if (accel == null || viewR.width <= iconR.width + textR.width + 3*textIconGap) {
            return;
        }

        final String acceleratorText = Utilities.getAcceleratorText(accel, acceleratorDelimiter);
View Full Code Here

     * Allow Dialog to be closed by ESC key
     */
    @Override
    protected JRootPane createRootPane() {
        JRootPane rootPane = new JRootPane();
        KeyStroke stroke = KeyStrokes.ESC;
        javax.swing.Action escapeAction = new AbstractAction("ESCAPE") {
            /**
             *
             */
            private static final long serialVersionUID = -4036804004190858925L;
View Full Code Here

                        textComponent.requestFocusInWindow();
                    }

                };
                final char key = attribute.charAt(0);
                final KeyStroke keystroke1
                    = KeyStroke.getKeyStroke(Character.toLowerCase(key),
                                             InputEvent.ALT_MASK);
                final KeyStroke keystroke2
                    = KeyStroke.getKeyStroke(Character.toUpperCase(key),
                                             InputEvent.ALT_MASK);
                textComponent.registerKeyboardAction(listener,
                                                     keystroke1,
                                                     JComponent
View Full Code Here

     * Loads the specified resource value as a key code.
     * @param key Property key value
     * @return Key code, or null if not specified or not found.
     */
    private Integer getKeyCode(String key) {
        KeyStroke ks = getKeyStroke(key);
        if(ks == null) return null;
        return ks.getKeyCode();
    }
View Full Code Here

TOP

Related Classes of javax.swing.KeyStroke

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.