Java源码示例:javax.swing.event.MenuKeyListener

示例1
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);
    }
}
 
示例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);
    }
}
 
示例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);
    }
}
 
示例4
/**
 * 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);
    }
}
 
示例5
/**
 * 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);
    }
}
 
示例6
/**
 * 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);
    }
}
 
示例7
/**
 * 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);
    }
}
 
示例8
/**
 * 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);
    }
}
 
示例9
/**
 * 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);
    }
}
 
示例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);
        }
    });
}
 
示例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);
        }
    });
}
 
示例12
/**
 * 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);
    }
}
 
示例13
/**
 * 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);
    }
}
 
示例14
public MenuKeyListener getMenuKeyListener() {
    return new InnerMenuKeyListener();
}