public MainPanel() { super(new BorderLayout()); InputMap im = table.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); KeyStroke tab = KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0); KeyStroke enter = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0); KeyStroke stab = KeyStroke.getKeyStroke(KeyEvent.VK_TAB, InputEvent.SHIFT_DOWN_MASK); KeyStroke senter = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, InputEvent.SHIFT_DOWN_MASK); im.put(tab, im.get(enter)); im.put(stab, im.get(senter)); final Color orgColor = table.getSelectionBackground(); final Color tflColor = this.getBackground(); table.addFocusListener( new FocusListener() { @Override public void focusGained(FocusEvent e) { table.setSelectionForeground(Color.WHITE); table.setSelectionBackground(orgColor); } @Override public void focusLost(FocusEvent e) { table.setSelectionForeground(Color.BLACK); table.setSelectionBackground(tflColor); } }); table.setComponentPopupMenu(new TablePopupMenu()); add(new JScrollPane(table)); setPreferredSize(new Dimension(320, 240)); }
public ImagePanel(Kdu_coords viewSize) throws KduException { int width = Math.min(viewSize.Get_x(), 1600); int height = Math.min(viewSize.Get_y(), 1200); setPreferredSize(new Dimension(width, height)); getInputMap().put(KeyStroke.getKeyStroke("UP"), "pressedUpArrow"); getActionMap() .put( "pressedUpArrow", new AbstractAction() { public void actionPerformed(ActionEvent evt) { // placeholder } }); getInputMap().put(KeyStroke.getKeyStroke("DOWN"), "pressedDownArrow"); getActionMap() .put( "pressedDownArrow", new AbstractAction() { public void actionPerformed(ActionEvent evt) { // placeholder } }); }
// --------> // original code: // ftp://ftp.oreilly.de/pub/examples/english_examples/jswing2/code/goodies/Mapper.java // modified by terai // private Hashtable<Object, ArrayList<KeyStroke>> buildReverseMap(InputMap im) { // Hashtable<Object, ArrayList<KeyStroke>> h = new Hashtable<>(); // if (Objects.isNull(im.allKeys())) { // return h; // } // for (KeyStroke ks: im.allKeys()) { // Object name = im.get(ks); // if (h.containsKey(name)) { // h.get(name).add(ks); // } else { // ArrayList<KeyStroke> keylist = new ArrayList<>(); // keylist.add(ks); // h.put(name, keylist); // } // } // return h; // } private void loadBindingMap(Integer focusType, InputMap im, ActionMap am) { if (Objects.isNull(im.allKeys())) { return; } ActionMap tmpAm = new ActionMap(); for (Object actionMapKey : am.allKeys()) { tmpAm.put(actionMapKey, am.get(actionMapKey)); } for (KeyStroke ks : im.allKeys()) { Object actionMapKey = im.get(ks); Action action = am.get(actionMapKey); if (Objects.isNull(action)) { model.addBinding(new Binding(focusType, "____" + actionMapKey.toString(), ks.toString())); } else { model.addBinding(new Binding(focusType, actionMapKey.toString(), ks.toString())); } tmpAm.remove(actionMapKey); } if (Objects.isNull(tmpAm.allKeys())) { return; } for (Object actionMapKey : tmpAm.allKeys()) { model.addBinding(new Binding(focusType, actionMapKey.toString(), "")); } }
private ActionToolbar createToolbar() { DefaultActionGroup group = new DefaultActionGroup(); BackAction back = new BackAction(); back.registerCustomShortcutSet( new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, 0)), this); group.add(back); ForwardAction forward = new ForwardAction(); forward.registerCustomShortcutSet( new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, 0)), this); group.add(forward); EditSourceActionBase edit = new EditSourceAction(); edit.registerCustomShortcutSet( new CompositeShortcutSet(CommonShortcuts.getEditSource(), CommonShortcuts.ENTER), this); group.add(edit); edit = new ShowSourceAction(); edit.registerCustomShortcutSet( new CompositeShortcutSet(CommonShortcuts.getViewSource(), CommonShortcuts.CTRL_ENTER), this); group.add(edit); return ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, group, true); }
private void initKeyMap() { InputMap map = this.getInputMap(); int shift = InputEvent.SHIFT_MASK; int ctrl = InputEvent.CTRL_MASK; map.put(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, shift), SikuliEditorKit.deIndentAction); map.put(KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, ctrl), SikuliEditorKit.deIndentAction); }
public ActionFrame() { setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT); buttonPanel = new JPanel(); // define actions Action yellowAction = new ColorAction("Yellow", new ImagIcon("yellow-ball.gif"), Color.YELLOW); Action blueAction = new ColorAction("Blue", new ImageIcon("blue-ball.gif"), Color.BLUE); Action redAction = new ColorAction("Red", new ImageIcon("red-ball.gif"), Color.RED); // add buttons for these actions buttonPanel.add(new JButton(yellowAction)); buttonPanel.add(new JButton(blueAction)); buttonPanel.add(new JButton(recAction)); // add panel to frame add(buttonPanel); // associate the Y, B, and R keys with names InputMap imap = buttonPanel.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); imap.put(KeyStroke.getKeyStroke("ctrl Y"), "panel.yellow"); imap.put(KeyStroke.getKeyStroke("Ctrl B"), "panel.blue"); imap.put(KeyStroke.getKeyStroke("ctrl R"), "panel.red"); // associate the names with actions ActionMap amap = buttonPanel.getActionMap(); amap.put("panel.yellow", yellowAction); amap.put("panel.blue", blueAction); amap.put("panel.red", redAction); }
/** * Converts a KeyStroke into a string representation for preference storage. * * @param prefsStroke the KeyStroke to convert * @return a string representation of the form "modifiers keyCode" or <code>null</code> * if the prefsStroke is invalid or <code>null</code> */ public static final String strokeToPrefs(KeyStroke prefsStroke) { if (prefsStroke == null) return null; else return String.valueOf(prefsStroke.getModifiers()) + ' ' + String.valueOf(prefsStroke.getKeyCode()); }
private void initWizard(final String title) { setTitle(title); myCurrentStep = 0; myPreviousButton = new JButton(IdeBundle.message("button.wizard.previous")); myNextButton = new JButton(IdeBundle.message("button.wizard.next")); myCancelButton = new JButton(CommonBundle.getCancelButtonText()); myHelpButton = new JButton(CommonBundle.getHelpButtonText()); myContentPanel = new JPanel(new CardLayout()); myIcon = new TallImageComponent(null); JRootPane rootPane = getRootPane(); if (rootPane != null) { // it will be null in headless mode, i.e. tests rootPane.registerKeyboardAction( new ActionListener() { public void actionPerformed(final ActionEvent e) { helpAction(); } }, KeyStroke.getKeyStroke(KeyEvent.VK_F1, 0), JComponent.WHEN_IN_FOCUSED_WINDOW); rootPane.registerKeyboardAction( new ActionListener() { public void actionPerformed(final ActionEvent e) { helpAction(); } }, KeyStroke.getKeyStroke(KeyEvent.VK_HELP, 0), JComponent.WHEN_IN_FOCUSED_WINDOW); } }
/** * This is hack. AWT doesn't allow to create KeyStroke with specified key code and key char * simultaneously. Therefore we are using reflection. */ private static KeyStroke getKeyStrokeWithoutMouseModifiers(KeyStroke originalKeyStroke) { int modifier = originalKeyStroke.getModifiers() & ~InputEvent.BUTTON1_DOWN_MASK & ~InputEvent.BUTTON1_MASK & ~InputEvent.BUTTON2_DOWN_MASK & ~InputEvent.BUTTON2_MASK & ~InputEvent.BUTTON3_DOWN_MASK & ~InputEvent.BUTTON3_MASK; try { Method[] methods = AWTKeyStroke.class.getDeclaredMethods(); Method getCachedStrokeMethod = null; for (Method method : methods) { if (GET_CACHED_STROKE_METHOD_NAME.equals(method.getName())) { getCachedStrokeMethod = method; getCachedStrokeMethod.setAccessible(true); break; } } if (getCachedStrokeMethod == null) { throw new IllegalStateException("not found method with name getCachedStrokeMethod"); } Object[] getCachedStrokeMethodArgs = new Object[] { originalKeyStroke.getKeyChar(), originalKeyStroke.getKeyCode(), modifier, originalKeyStroke.isOnKeyRelease() }; return (KeyStroke) getCachedStrokeMethod.invoke(originalKeyStroke, getCachedStrokeMethodArgs); } catch (Exception exc) { throw new IllegalStateException(exc.getMessage()); } }
@Override public KeyStroke[] getClearBufferKeyStrokes() { return new KeyStroke[] { UIUtil.isMac ? KeyStroke.getKeyStroke(KeyEvent.VK_K, InputEvent.META_DOWN_MASK) : KeyStroke.getKeyStroke(KeyEvent.VK_K, InputEvent.CTRL_DOWN_MASK) }; }
private void init() { getActionMap().put("startEditing", new StartEditingAction()); // NOI18N getActionMap().put("cancel", new CancelEditingAction()); // NOI18N addMouseListener(new MouseListener()); getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_F2, 0), "startEditing"); // NOI18N getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT) .put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "cancel"); // NOI18N putClientProperty("terminateEditOnFocusLost", Boolean.TRUE); // NOI18N }
@Override public KeyStroke[] getCloseSessionKeyStrokes() { return new KeyStroke[] { UIUtil.isMac ? KeyStroke.getKeyStroke(KeyEvent.VK_W, InputEvent.META_DOWN_MASK) : KeyStroke.getKeyStroke( KeyEvent.VK_W, InputEvent.CTRL_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK) }; }
@Override protected JRootPane createRootPane() { JRootPane jrootPane = new JRootPane(); int menuShortcutKey = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(); KeyStroke w = KeyStroke.getKeyStroke(KeyEvent.VK_W, menuShortcutKey); KeyStroke esc = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0); jrootPane.registerKeyboardAction(this, ACTION_CLOSE, w, JComponent.WHEN_IN_FOCUSED_WINDOW); jrootPane.registerKeyboardAction(this, ACTION_CLOSE, esc, JComponent.WHEN_IN_FOCUSED_WINDOW); return jrootPane; }
@Override public KeyStroke[] getPasteKeyStrokes() { return new KeyStroke[] { UIUtil.isMac ? KeyStroke.getKeyStroke(KeyEvent.VK_V, InputEvent.META_DOWN_MASK) // CTRL + V is used for signal; use CTRL + SHIFT + V instead : KeyStroke.getKeyStroke( KeyEvent.VK_V, InputEvent.CTRL_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK) }; }
private static void installActions(JTable table) { InputMap inputMap = table.getInputMap(WHEN_FOCUSED); inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_END, 0), "selectLastRow"); inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_HOME, 0), "selectFirstRow"); inputMap.put( KeyStroke.getKeyStroke(KeyEvent.VK_HOME, KeyEvent.SHIFT_DOWN_MASK), "selectFirstRowExtendSelection"); inputMap.put( KeyStroke.getKeyStroke(KeyEvent.VK_END, KeyEvent.SHIFT_DOWN_MASK), "selectLastRowExtendSelection"); }
/** * The Excel Adapter is constructed with a JTable on which it enables Copy-Paste and acts as a * Clipboard listener. */ public ExcelAdapter(JTable myJTable) { jTable1 = myJTable; KeyStroke copy = KeyStroke.getKeyStroke(KeyEvent.VK_C, ActionEvent.CTRL_MASK, false); // Identifying the copy KeyStroke user can modify this // to copy on some other Key combination. KeyStroke paste = KeyStroke.getKeyStroke(KeyEvent.VK_V, ActionEvent.CTRL_MASK, false); // Identifying the Paste KeyStroke user can modify this // to copy on some other Key combination. jTable1.registerKeyboardAction(this, "Copy", copy, JComponent.WHEN_FOCUSED); jTable1.registerKeyboardAction(this, "Paste", paste, JComponent.WHEN_FOCUSED); system = Toolkit.getDefaultToolkit().getSystemClipboard(); }
private JMenuBar createMenuBar() { JMenu menu = new JMenu("Menu"); disablingItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_D, InputEvent.ALT_MASK)); menu.add(disablingItem); menu.addSeparator(); blurItem.setSelected(true); blurItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_1, InputEvent.ALT_MASK)); menu.add(blurItem); embossItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_2, InputEvent.ALT_MASK)); menu.add(embossItem); busyPainterItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_3, InputEvent.ALT_MASK)); menu.add(busyPainterItem); ButtonGroup group = new ButtonGroup(); group.add(blurItem); group.add(embossItem); group.add(busyPainterItem); ItemListener menuListener = new ItemListener() { public void itemStateChanged(ItemEvent e) { if (blurItem.isSelected()) { // layer.setUI(blurUI); } else if (embossItem.isSelected()) { // layer.setUI(embossUI); } else if (busyPainterItem.isSelected()) { layer.setUI(busyPainterUI); } } }; blurItem.addItemListener(menuListener); embossItem.addItemListener(menuListener); busyPainterItem.addItemListener(menuListener); // embossUI.getUnlockButton().addActionListener(new ActionListener() { // public void actionPerformed(ActionEvent e) { // disablingItem.doClick(); // } // }); JMenuBar bar = new JMenuBar(); bar.add(menu); bar.add(new LafMenu()); return bar; }
private void initActions() { @NonNls InputMap inputMap = getInputMap(WHEN_FOCUSED); inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0, false), "moveFocusDown"); inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_UP, 0, false), "moveFocusUp"); inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, 0, false), "collapse"); inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, 0, false), "expand"); @NonNls ActionMap actionMap = getActionMap(); actionMap.put("moveFocusDown", new MoveFocusAction(true)); actionMap.put("moveFocusUp", new MoveFocusAction(false)); actionMap.put("collapse", new ExpandAction(false)); actionMap.put("expand", new ExpandAction(true)); }
private void initKeyMaps() { // Down-arrow nudges this Spacer downward: registerKeyboardAction( new AbstractAction() { public void actionPerformed(ActionEvent event) { Point p = getLocation(); moveTo(p.y + 1); } }, KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0), WHEN_FOCUSED); // Up-arrow nudges this Spacer upward: registerKeyboardAction( new AbstractAction() { public void actionPerformed(ActionEvent event) { Point p = getLocation(); moveTo(p.y - 1); } }, KeyStroke.getKeyStroke(KeyEvent.VK_UP, 0), WHEN_FOCUSED); // Space sticks this Spacer where it is: registerKeyboardAction( new AbstractAction() { public void actionPerformed(ActionEvent event) { Point p = getLocation(); moveTo(p.y); } }, KeyStroke.getKeyStroke(KeyEvent.VK_X, 0), WHEN_FOCUSED); // Delete unsticks this Spacer: registerKeyboardAction( new AbstractAction() { public void actionPerformed(ActionEvent event) { model.removePoint(index); } }, KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), WHEN_FOCUSED); // Backspace is same as Delete: registerKeyboardAction( new AbstractAction() { public void actionPerformed(ActionEvent event) { model.removePoint(index); } }, KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, 0), WHEN_FOCUSED); }
private void registerKeyStrokes() { KeyStroke keyStroke; Action act; keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, Event.CTRL_MASK); act = new AbstractAction() { public void actionPerformed(ActionEvent e) { onRightCtrl(); } }; _textPane.getKeymap().addActionForKeyStroke(keyStroke, act); keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, Event.CTRL_MASK | Event.SHIFT_MASK); act = new AbstractAction() { public void actionPerformed(ActionEvent e) { onRightCtrlShift(); } }; _textPane.getKeymap().addActionForKeyStroke(keyStroke, act); keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, Event.CTRL_MASK); act = new AbstractAction() { public void actionPerformed(ActionEvent e) { onLeftCtrl(); } }; _textPane.getKeymap().addActionForKeyStroke(keyStroke, act); keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, Event.CTRL_MASK | Event.SHIFT_MASK); act = new AbstractAction() { public void actionPerformed(ActionEvent e) { onLeftCtrlShift(); } }; _textPane.getKeymap().addActionForKeyStroke(keyStroke, act); keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, Event.CTRL_MASK); act = new AbstractAction() { public void actionPerformed(ActionEvent e) { onCtrlBackSpace(); } }; _textPane.getKeymap().addActionForKeyStroke(keyStroke, act); }
public static JDialog createDialog(JComponent parent, OWLEditorKit editorKit) { JFrame parentFrame = (JFrame) SwingUtilities.getAncestorOfClass(JFrame.class, parent); final JDialog dialog = new JDialog(parentFrame, "Search", Dialog.ModalityType.MODELESS); final SearchDialogPanel searchDialogPanel = new SearchDialogPanel(editorKit); searchDialogPanel.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); searchDialogPanel .getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT) .put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "CLOSE_DIALOG"); searchDialogPanel .getActionMap() .put( "CLOSE_DIALOG", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { dialog.setVisible(false); } }); searchDialogPanel .getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT) .put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "CLOSE_DIALOG_WITH_ENTER"); searchDialogPanel .getActionMap() .put( "CLOSE_DIALOG_WITH_ENTER", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { dialog.setVisible(false); searchDialogPanel.selectEntity(); } }); dialog.setContentPane(searchDialogPanel); dialog.setResizable(true); dialog.pack(); dialog.addWindowListener( new WindowAdapter() { @Override public void windowOpened(WindowEvent e) { searchDialogPanel.searchField.requestFocusInWindow(); } }); return dialog; }
public AboutAction() { putValue(Action.NAME, "about"); putValue(Action.SHORT_DESCRIPTION, "About the author"); putValue(Action.ACTION_COMMAND_KEY, "about"); putValue(Action.MNEMONIC_KEY, new Integer(java.awt.event.KeyEvent.VK_A)); putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke("F9")); }
public Action4() { putValue(Action.NAME, "action4"); putValue(Action.SHORT_DESCRIPTION, "Toggle Action 4"); putValue(Action.ACTION_COMMAND_KEY, "action4"); putValue(Action.MNEMONIC_KEY, new Integer(java.awt.event.KeyEvent.VK_4)); putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke("F4")); }
public ImportAction(JDesktopPane parent, SipModel sipModel) { super("Import new source data"); putValue(Action.SMALL_ICON, SwingHelper.ICON_IMPORT); putValue( Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke( KeyEvent.VK_I, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); this.parent = parent; this.sipModel = sipModel; this.dialog = new JDialog( SwingUtilities.getWindowAncestor(parent), "Input Source", Dialog.ModalityType.APPLICATION_MODAL); setEnabled(false); prepareDialog(); prepareChooser(sipModel); sipModel .getDataSetModel() .addListener( new DataSetModel.SwingListener() { @Override public void stateChanged(DataSetModel model, DataSetState state) { setEnabled(state != ABSENT); } }); }
public TaskbarPositionTest() { super("Use CTRL-down to show a JPopupMenu"); setContentPane(panel = createContentPane()); setJMenuBar(createMenuBar("1 - First Menu", true)); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // CTRL-down will show the popup. panel .getInputMap() .put(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, InputEvent.CTRL_MASK), "OPEN_POPUP"); panel.getActionMap().put("OPEN_POPUP", new PopupHandler()); pack(); Toolkit toolkit = Toolkit.getDefaultToolkit(); fullScreenBounds = new Rectangle(new Point(), toolkit.getScreenSize()); screenBounds = new Rectangle(new Point(), toolkit.getScreenSize()); // Place the frame near the bottom. This is a pretty wild guess. this.setLocation(0, (int) screenBounds.getHeight() - 2 * this.getHeight()); // Reduce the screen bounds by the insets. GraphicsConfiguration gc = this.getGraphicsConfiguration(); if (gc != null) { Insets screenInsets = toolkit.getScreenInsets(gc); screenBounds = gc.getBounds(); screenBounds.width -= (screenInsets.left + screenInsets.right); screenBounds.height -= (screenInsets.top + screenInsets.bottom); screenBounds.x += screenInsets.left; screenBounds.y += screenInsets.top; } setVisible(true); }
public void unbindKey(String keySequence) { KeyStroke ks = KeyStroke.getKeyStroke(keySequence); if (ks == null) { throw new Error("Invalid key sequence \"" + keySequence + "\""); } textView.getKeymap().removeKeyStrokeBinding(ks); }
private void removeCTRLTabFromFocusTraversal() { KeyStroke ctrlTab = KeyStroke.getKeyStroke("ctrl TAB"); Set<AWTKeyStroke> forwardKeys = new HashSet<>(this.getFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS)); forwardKeys.remove(ctrlTab); this.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, forwardKeys); }
/** * Constructs an image edit mode with specified manager. * * @param modeManager the mode manager for this mode. */ public ImageEditMode(ModeManager modeManager, PixelsView pixels, float vnull, float[][] v) { super(modeManager); setName("Edit"); // setIcon(loadIcon(ImageEditMode.class,"resources/ImageEdit16.gif")); // setIcon(loadIcon(MouseTrackMode.class,"resources/Track24.gif")); setMnemonicKey(KeyEvent.VK_E); setAcceleratorKey(KeyStroke.getKeyStroke(KeyEvent.VK_E, 0)); setShortDescription("Edit points"); _tile = pixels.getTile(); _pixels = pixels; fill(vnull, v); _vnull = vnull; _n1 = v[0].length; _n2 = v.length; _v = v; _is2 = new ImageSampler2(_v); _ns = 0; _x1 = new float[0][0]; _x2 = new float[0][0]; _vx = new float[0][0]; _points = new PointsView(_x1, _x2); if (pixels.getOrientation() == PixelsView.Orientation.X1RIGHT_X2UP) { _points.setOrientation(PointsView.Orientation.X1RIGHT_X2UP); } else { _points.setOrientation(PointsView.Orientation.X1DOWN_X2RIGHT); } _points.setStyle("w-o"); }
private void registerShortcuts() { ActionManager actionManager = ActionManager.getInstance(); actionManager .getAction(XDebuggerActions.SET_VALUE) .registerCustomShortcutSet( new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_F2, 0)), this); actionManager .getAction(XDebuggerActions.COPY_VALUE) .registerCustomShortcutSet(CommonShortcuts.getCopy(), this); actionManager .getAction(XDebuggerActions.JUMP_TO_SOURCE) .registerCustomShortcutSet(CommonShortcuts.getEditSource(), this); Shortcut[] editTypeShortcuts = KeymapManager.getInstance() .getActiveKeymap() .getShortcuts(XDebuggerActions.EDIT_TYPE_SOURCE); actionManager .getAction(XDebuggerActions.JUMP_TO_TYPE_SOURCE) .registerCustomShortcutSet(new CustomShortcutSet(editTypeShortcuts), this); actionManager .getAction(XDebuggerActions.MARK_OBJECT) .registerCustomShortcutSet( new CustomShortcutSet( KeymapManager.getInstance().getActiveKeymap().getShortcuts("ToggleBookmark")), this); }
private JPanel createContentPane() { JPanel panel = new JPanel(); combo1 = new JComboBox<>(numData); panel.add(combo1); combo2 = new JComboBox<>(dayData); combo2.setEditable(true); panel.add(combo2); panel.setSize(300, 200); popupMenu = new JPopupMenu(); JMenuItem item; for (int i = 0; i < dayData.length; i++) { item = popupMenu.add(new JMenuItem(dayData[i], mnDayData[i])); item.addActionListener(this); } panel.addMouseListener(new PopupListener(popupMenu)); JTextField field = new JTextField("CTRL+down for Popup"); // CTRL-down will show the popup. field .getInputMap() .put(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, InputEvent.CTRL_MASK), "OPEN_POPUP"); field.getActionMap().put("OPEN_POPUP", new PopupHandler()); panel.add(field); return panel; }