/** * Registers all actions registered on the source component and registered them on the target component at the * specified condition. * * @param sourceComponent the source component. * @param targetComponent the target component. * @param keyStrokes the keystrokes * @param condition the condition which will be used in {@link javax.swing.JComponent#registerKeyboardAction(java.awt.event.ActionListener, * javax.swing.KeyStroke, int)} as the last parameter. */ public static void synchronizeKeyboardActions(JComponent sourceComponent, JComponent targetComponent, KeyStroke[] keyStrokes, int condition) { for (KeyStroke keyStroke : keyStrokes) { ActionListener actionListener = sourceComponent.getActionForKeyStroke(keyStroke); if (actionListener != null) { targetComponent.registerKeyboardAction(actionListener, keyStroke, condition); } } }
public void actionPerformed(ActionEvent e) { TabPagerManager te = TabPagerManager.getPager(); if (te.isVisible()) { te.hide(); } else { // fix for defect 233 on Substance - the key event // is not dispatched when tab pager is not showing. Component comp = jcomp.getParent(); while (comp != null) { if (comp instanceof JComponent) { JComponent jc = (JComponent) comp; KeyStroke escapeKeyStroke = KeyStroke.getKeyStroke( KeyEvent.VK_ESCAPE, 0, false); ActionListener al = jc .getActionForKeyStroke(escapeKeyStroke); if (al != null) { al.actionPerformed(e); return; } } comp = comp.getParent(); } } } });
public static void restoreAction(JComponent component, int condition, KeyStroke keyStroke) { if (component == null) { return; } ActionListener action = component.getActionForKeyStroke(keyStroke); if (action instanceof DelegateAction) { Action actualAction = ((DelegateAction) action).getAction(); if (actualAction != null) { component.registerKeyboardAction(actualAction, keyStroke, condition); } else { component.unregisterKeyboardAction(keyStroke); } } }
private void performJavaDocAction(KeyStroke ks){ ActionListener act = getJavaDocPane().getJavadocDisplayComponent().getActionForKeyStroke(ks); if (act!=null){ act.actionPerformed(new ActionEvent(getJavaDocPane().getJavadocDisplayComponent(), ActionEvent.ACTION_PERFORMED, "")); //NOI18N getJavaDocPane().getJavadocDisplayComponent().repaint(); } }
private void performJavaDocAction(KeyStroke ks){ ActionListener act = getJavaDocPane().getJavadocDisplayComponent().getActionForKeyStroke(ks); if (act!=null){ act.actionPerformed(new ActionEvent(getJavaDocPane().getJavadocDisplayComponent(), ActionEvent.ACTION_PERFORMED, "")); //NOI18N getJavaDocPane().getJavadocDisplayComponent().repaint(); } }
final ActionListener ctrlVAction = editorPane.getActionForKeyStroke(ctrlV); editorPane.registerKeyboardAction(new CombinedAction(ctrlVAction, new ActionListener() {
private State handleKeyEvent (Widget widget, WidgetKeyEvent event, KeyStroke keyStroke) { ActionListener action; if (actionMap != null && inputMap != null) { Object o = inputMap.get (keyStroke); action = o != null ? actionMap.get (o) : null; } else { JComponent view = widget.getScene ().getView (); action = view != null ? view.getActionForKeyStroke (keyStroke) : null; } if (action != null) { action.actionPerformed (new ActionEvent (widget, (int) event.getEventID (), null, event.getWhen (), event.getModifiers ())); // TODO - action-event command return State.CONSUMED; } return State.REJECTED; }
private State handleKeyEvent (Widget widget, WidgetKeyEvent event, KeyStroke keyStroke) { if (keyStroke == null) return State.REJECTED; ActionListener action; if (actionMap != null && inputMap != null) { Object o = inputMap.get (keyStroke); action = o != null ? actionMap.get (o) : null; } else { JComponent view = widget.getScene ().getView (); action = view != null ? view.getActionForKeyStroke (keyStroke) : null; } if (action != null) { action.actionPerformed (new ActionEvent (widget, (int) event.getEventID (), null, event.getWhen (), event.getModifiers ())); // TODO - action-event command return State.CONSUMED; } return State.REJECTED; }
private State handleKeyEvent (Widget widget, WidgetKeyEvent event, KeyStroke keyStroke) { if (keyStroke == null) return State.REJECTED; ActionListener action; if (actionMap != null && inputMap != null) { Object o = inputMap.get (keyStroke); action = o != null ? actionMap.get (o) : null; } else { JComponent view = widget.getScene ().getView (); action = view != null ? view.getActionForKeyStroke (keyStroke) : null; } if (action != null) { action.actionPerformed (new ActionEvent (widget, (int) event.getEventID (), null, event.getWhen (), event.getModifiers ())); // TODO - action-event command return State.CONSUMED; } return State.REJECTED; }
public static void restoreAction(JComponent component, int condition, KeyStroke keyStroke, Class<?> actionClass) { ActionListener action = component.getActionForKeyStroke(keyStroke); ActionListener parent = action; ActionListener top = action; while (action instanceof DelegateAction) { if (actionClass.isAssignableFrom(action.getClass())) { if (top == action) { Action a = ((DelegateAction) action).getAction(); if (a == null) { component.unregisterKeyboardAction(keyStroke); } else { component.registerKeyboardAction(a, keyStroke, condition); } } else { ((DelegateAction) parent).setAction(((DelegateAction) action).getAction()); } break; } parent = action; action = ((DelegateAction) action).getAction(); } }
public static void restoreAction(JComponent component, int condition, KeyStroke keyStroke, Action actionToBeRemoved) { ActionListener action = component.getActionForKeyStroke(keyStroke); ActionListener parent = action; ActionListener top = action; while (action instanceof DelegateAction) { if (actionToBeRemoved == action) { if (top == action) { component.registerKeyboardAction(((DelegateAction) action).getAction(), keyStroke, condition); } else { ((DelegateAction) parent).setAction(((DelegateAction) action).getAction()); } break; } parent = action; action = ((DelegateAction) action).getAction(); } } }
public static void replaceAction(JComponent component, int condition, JComponent target, int targetCondition, KeyStroke keyStroke, DelegateAction delegateAction, boolean first) { ActionListener action = component.getActionForKeyStroke(keyStroke); if (action != delegateAction && action instanceof Action) { if (!first && action instanceof DelegateAction) {