Java Code Examples for javax.swing.event.MenuKeyListener

The following examples show how to use javax.swing.event.MenuKeyListener. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: darklaf   Source File: PopupMenuContainer.java    License: MIT License 5 votes vote down vote up
public void setPopupMenu(final JPopupMenu popupMenu) {
    MenuKeyListener keyListener = getMenuKeyListener();
    PopupMenuListener popupMenuListener = getMenuListener();
    this.popupMenu = popupMenu;
    if (popupMenu != null) {
        popupMenu.removeMenuKeyListener(keyListener);
        popupMenu.removePopupMenuListener(popupMenuListener);
        popupMenu.addMenuKeyListener(keyListener);
        popupMenu.addPopupMenuListener(popupMenuListener);
    }
}
 
Example 2
/**
 * Registers a component for tooltip management.
 * <p>
 * This will register key bindings to show and hide the tooltip text
 * only if <code>component</code> has focus bindings. This is done
 * so that components that are not normally focus traversable, such
 * as <code>JLabel</code>, are not made focus traversable as a result
 * of invoking this method.
 *
 * @param component  a <code>JComponent</code> object to add
 * @see JComponent#isFocusTraversable
 */
public void registerComponent(JComponent component) {
    component.removeMouseListener(this);
    component.addMouseListener(this);
    component.removeMouseMotionListener(moveBeforeEnterListener);
    component.addMouseMotionListener(moveBeforeEnterListener);
    // use MenuKeyListener for menu items/elements
    if (component instanceof JMenuItem) {
        ((JMenuItem) component).removeMenuKeyListener((MenuKeyListener) accessibilityKeyListener);
        ((JMenuItem) component).addMenuKeyListener((MenuKeyListener) accessibilityKeyListener);
    } else {
        component.removeKeyListener(accessibilityKeyListener);
        component.addKeyListener(accessibilityKeyListener);
    }
}
 
Example 3
/**
 * Removes a component from tooltip control.
 *
 * @param component  a <code>JComponent</code> object to remove
 */
public void unregisterComponent(JComponent component) {
    component.removeMouseListener(this);
    component.removeMouseMotionListener(moveBeforeEnterListener);
    if (component instanceof JMenuItem) {
        ((JMenuItem) component).removeMenuKeyListener((MenuKeyListener) accessibilityKeyListener);
    } else {
        component.removeKeyListener(accessibilityKeyListener);
    }
}
 
Example 4
Source Project: TencentKona-8   Source File: ToolTipManager.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Registers a component for tooltip management.
 * <p>
 * This will register key bindings to show and hide the tooltip text
 * only if <code>component</code> has focus bindings. This is done
 * so that components that are not normally focus traversable, such
 * as <code>JLabel</code>, are not made focus traversable as a result
 * of invoking this method.
 *
 * @param component  a <code>JComponent</code> object to add
 * @see JComponent#isFocusTraversable
 */
public void registerComponent(JComponent component) {
    component.removeMouseListener(this);
    component.addMouseListener(this);
    component.removeMouseMotionListener(moveBeforeEnterListener);
    component.addMouseMotionListener(moveBeforeEnterListener);
    // use MenuKeyListener for menu items/elements
    if (component instanceof JMenuItem) {
        ((JMenuItem) component).removeMenuKeyListener((MenuKeyListener) accessibilityKeyListener);
        ((JMenuItem) component).addMenuKeyListener((MenuKeyListener) accessibilityKeyListener);
    } else {
        component.removeKeyListener(accessibilityKeyListener);
        component.addKeyListener(accessibilityKeyListener);
    }
}
 
Example 5
Source Project: TencentKona-8   Source File: ToolTipManager.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Removes a component from tooltip control.
 *
 * @param component  a <code>JComponent</code> object to remove
 */
public void unregisterComponent(JComponent component) {
    component.removeMouseListener(this);
    component.removeMouseMotionListener(moveBeforeEnterListener);
    if (component instanceof JMenuItem) {
        ((JMenuItem) component).removeMenuKeyListener((MenuKeyListener) accessibilityKeyListener);
    } else {
        component.removeKeyListener(accessibilityKeyListener);
    }
}
 
Example 6
Source Project: openjdk-jdk8u   Source File: ToolTipManager.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Registers a component for tooltip management.
 * <p>
 * This will register key bindings to show and hide the tooltip text
 * only if <code>component</code> has focus bindings. This is done
 * so that components that are not normally focus traversable, such
 * as <code>JLabel</code>, are not made focus traversable as a result
 * of invoking this method.
 *
 * @param component  a <code>JComponent</code> object to add
 * @see JComponent#isFocusTraversable
 */
public void registerComponent(JComponent component) {
    component.removeMouseListener(this);
    component.addMouseListener(this);
    component.removeMouseMotionListener(moveBeforeEnterListener);
    component.addMouseMotionListener(moveBeforeEnterListener);
    // use MenuKeyListener for menu items/elements
    if (component instanceof JMenuItem) {
        ((JMenuItem) component).removeMenuKeyListener((MenuKeyListener) accessibilityKeyListener);
        ((JMenuItem) component).addMenuKeyListener((MenuKeyListener) accessibilityKeyListener);
    } else {
        component.removeKeyListener(accessibilityKeyListener);
        component.addKeyListener(accessibilityKeyListener);
    }
}
 
Example 7
Source Project: openjdk-jdk8u   Source File: ToolTipManager.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Removes a component from tooltip control.
 *
 * @param component  a <code>JComponent</code> object to remove
 */
public void unregisterComponent(JComponent component) {
    component.removeMouseListener(this);
    component.removeMouseMotionListener(moveBeforeEnterListener);
    if (component instanceof JMenuItem) {
        ((JMenuItem) component).removeMenuKeyListener((MenuKeyListener) accessibilityKeyListener);
    } else {
        component.removeKeyListener(accessibilityKeyListener);
    }
}
 
Example 8
Source Project: Bytecoder   Source File: ToolTipManager.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Registers a component for tooltip management.
 * <p>
 * This will register key bindings to show and hide the tooltip text
 * only if <code>component</code> has focus bindings. This is done
 * so that components that are not normally focus traversable, such
 * as <code>JLabel</code>, are not made focus traversable as a result
 * of invoking this method.
 *
 * @param component  a <code>JComponent</code> object to add
 * @see JComponent#isFocusTraversable
 */
public void registerComponent(JComponent component) {
    component.removeMouseListener(this);
    component.addMouseListener(this);
    component.removeMouseMotionListener(moveBeforeEnterListener);
    component.addMouseMotionListener(moveBeforeEnterListener);
    // use MenuKeyListener for menu items/elements
    if (component instanceof JMenuItem) {
        ((JMenuItem) component).removeMenuKeyListener((MenuKeyListener) accessibilityKeyListener);
        ((JMenuItem) component).addMenuKeyListener((MenuKeyListener) accessibilityKeyListener);
    } else {
        component.removeKeyListener(accessibilityKeyListener);
        component.addKeyListener(accessibilityKeyListener);
    }
}
 
Example 9
Source Project: Bytecoder   Source File: ToolTipManager.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Removes a component from tooltip control.
 *
 * @param component  a <code>JComponent</code> object to remove
 */
public void unregisterComponent(JComponent component) {
    component.removeMouseListener(this);
    component.removeMouseMotionListener(moveBeforeEnterListener);
    if (component instanceof JMenuItem) {
        ((JMenuItem) component).removeMenuKeyListener((MenuKeyListener) accessibilityKeyListener);
    } else {
        component.removeKeyListener(accessibilityKeyListener);
    }
}
 
Example 10
/**
 * Maps {@code JMenuItem.addMenuKeyListener(MenuKeyListener)} through queue
 */
public void addMenuKeyListener(final MenuKeyListener menuKeyListener) {
    runMapping(new MapVoidAction("addMenuKeyListener") {
        @Override
        public void map() {
            ((JMenuItem) getSource()).addMenuKeyListener(menuKeyListener);
        }
    });
}
 
Example 11
/**
 * Maps {@code JMenuItem.removeMenuKeyListener(MenuKeyListener)}
 * through queue
 */
public void removeMenuKeyListener(final MenuKeyListener menuKeyListener) {
    runMapping(new MapVoidAction("removeMenuKeyListener") {
        @Override
        public void map() {
            ((JMenuItem) getSource()).removeMenuKeyListener(menuKeyListener);
        }
    });
}
 
Example 12
Source Project: jdk8u_jdk   Source File: ToolTipManager.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Registers a component for tooltip management.
 * <p>
 * This will register key bindings to show and hide the tooltip text
 * only if <code>component</code> has focus bindings. This is done
 * so that components that are not normally focus traversable, such
 * as <code>JLabel</code>, are not made focus traversable as a result
 * of invoking this method.
 *
 * @param component  a <code>JComponent</code> object to add
 * @see JComponent#isFocusTraversable
 */
public void registerComponent(JComponent component) {
    component.removeMouseListener(this);
    component.addMouseListener(this);
    component.removeMouseMotionListener(moveBeforeEnterListener);
    component.addMouseMotionListener(moveBeforeEnterListener);
    // use MenuKeyListener for menu items/elements
    if (component instanceof JMenuItem) {
        ((JMenuItem) component).removeMenuKeyListener((MenuKeyListener) accessibilityKeyListener);
        ((JMenuItem) component).addMenuKeyListener((MenuKeyListener) accessibilityKeyListener);
    } else {
        component.removeKeyListener(accessibilityKeyListener);
        component.addKeyListener(accessibilityKeyListener);
    }
}
 
Example 13
Source Project: jdk8u_jdk   Source File: ToolTipManager.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Removes a component from tooltip control.
 *
 * @param component  a <code>JComponent</code> object to remove
 */
public void unregisterComponent(JComponent component) {
    component.removeMouseListener(this);
    component.removeMouseMotionListener(moveBeforeEnterListener);
    if (component instanceof JMenuItem) {
        ((JMenuItem) component).removeMenuKeyListener((MenuKeyListener) accessibilityKeyListener);
    } else {
        component.removeKeyListener(accessibilityKeyListener);
    }
}
 
Example 14
Source Project: freecol   Source File: FreeColAction.java    License: GNU General Public License v2.0 4 votes vote down vote up
public MenuKeyListener getMenuKeyListener() {
    return new InnerMenuKeyListener();
}