javax.swing.plaf.basic.BasicMenuItemUI Java Examples
The following examples show how to use
javax.swing.plaf.basic.BasicMenuItemUI.
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 File: GtkPaintingUtil.java From consulo with Apache License 2.0 | 6 votes |
public static void paintDisabledText(final BasicMenuItemUI originalUI, final Graphics g, final JMenuItem menuItem, final Rectangle textRect, final String text) { final FontMetrics fm = SwingUtilities2.getFontMetrics(menuItem, g); final int index = menuItem.getDisplayedMnemonicIndex(); final Color fg = getForeground(originalUI, menuItem); final Color shadow = UIUtil.shade(menuItem.getBackground(), 1.24, 0.5); g.setColor(shadow); SwingUtilities2.drawStringUnderlineCharAt(menuItem, g, text, index, textRect.x + 1, textRect.y + fm.getAscent() + 1); g.setColor(fg); SwingUtilities2.drawStringUnderlineCharAt(menuItem, g, text, index, textRect.x, textRect.y + fm.getAscent()); }
Example #2
Source File: GtkMenuItemUI.java From consulo with Apache License 2.0 | 5 votes |
private static Icon getCheckIconFromContext(final BasicMenuItemUI originalUI, final JCheckBoxMenuItem item) { if (myCachedCheckIcon == null) { final SynthContext context = GtkPaintingUtil.getSynthContext(originalUI, item); myCachedCheckIcon = context.getStyle().getIcon(context, "CheckBoxMenuItem.checkIcon"); } return myCachedCheckIcon; }
Example #3
Source File: MainPanel.java From java-swing-tips with MIT License | 4 votes |
@Override protected MouseInputListener createMouseInputListener(JComponent c) { return new BasicMenuItemUI.MouseInputHandler() { @Override public void mousePressed(MouseEvent e) { JMenu menu = (JMenu) menuItem; if (!menu.isEnabled() || SwingUtilities.isRightMouseButton(e)) { return; } super.mousePressed(e); // MenuSelectionManager manager = MenuSelectionManager.defaultManager(); // if (menu.isTopLevelMenu()) { // if (menu.isSelected() && menu.getPopupMenu().isShowing()) { // manager.clearSelectedPath(); // } else { // Container cnt = menu.getParent(); // if (cnt instanceof JMenuBar) { // MenuElement[] me = new MenuElement[2]; // me[0] = (MenuElement) cnt; // me[1] = menu; // manager.setSelectedPath(me); // } // } // } // MenuElement[] selectedPath = manager.getSelectedPath(); // if (selectedPath.length > 0 && selectedPath[selectedPath.length - 1] != menu.getPopupMenu()) { // if (menu.isTopLevelMenu() || menu.getDelay() == 0) { // MenuElement[] newPath = new MenuElement[selectedPath.length + 1]; // System.arraycopy(selectedPath, 0, newPath, 0, selectedPath.length); // newPath[selectedPath.length] = menu.getPopupMenu(); // MenuSelectionManager.defaultManager().setSelectedPath(newPath); // } else { // setupPostTimer(menu); // } // } } // @Override public void mouseReleased(MouseEvent e) { // JMenu menu = (JMenu) menuItem; // if (!menu.isEnabled()) { // return; // } // MenuSelectionManager manager = MenuSelectionManager.defaultManager(); // manager.processMouseEvent(e); // if (!e.isConsumed()) { // manager.clearSelectedPath(); // } // } // @Override public void mouseEntered(MouseEvent e) { // MenuSelectionManager manager = MenuSelectionManager.defaultManager(); // int modifiers = e.getModifiersEx(); // if ((modifiers & InputEvent.BUTTON1_DOWN_MASK) != 0) { // MenuSelectionManager.defaultManager().processMouseEvent(e); // } else { // manager.setSelectedPath(getPath()); // } // } // @Override public void mouseExited(MouseEvent e) { // MenuSelectionManager manager = MenuSelectionManager.defaultManager(); // int modifiers = e.getModifiersEx(); // if ((modifiers & InputEvent.BUTTON1_DOWN_MASK) != 0) { // MenuSelectionManager.defaultManager().processMouseEvent(e); // } else { // MenuElement[] path = manager.getSelectedPath(); // if (path.length > 1 && path[path.length - 1] == menuItem) { // MenuElement[] newPath = new MenuElement[path.length - 1]; // System.arraycopy(path, 0, newPath, 0, path.length - 1); // manager.setSelectedPath(newPath); // } // } // } // @Override public void mouseDragged(MouseEvent e) { // MenuSelectionManager.defaultManager().processMouseEvent(e); // } }; }
Example #4
Source File: MainPanel.java From java-swing-tips with MIT License | 4 votes |
@Override protected MouseInputListener createMouseInputListener(JComponent c) { return new BasicMenuItemUI.MouseInputHandler() { @Override public void mouseReleased(MouseEvent e) { if (!menuItem.isEnabled() || SwingUtilities.isRightMouseButton(e)) { return; } super.mouseReleased(e); // MenuSelectionManager manager = MenuSelectionManager.defaultManager(); // Point p = e.getPoint(); // if (p.x >= 0 && p.x < menuItem.getWidth() && p.y >= 0 && p.y < menuItem.getHeight()) { // doClick(manager); // } else { // manager.processMouseEvent(e); // } } // @Override public void mouseEntered(MouseEvent e) { // MenuSelectionManager manager = MenuSelectionManager.defaultManager(); // int modifiers = e.getModifiersEx(); // if ((modifiers & InputEvent.BUTTON1_DOWN_MASK) != 0) { // MenuSelectionManager.defaultManager().processMouseEvent(e); // } else { // manager.setSelectedPath(getPath()); // } // } // @Override public void mouseExited(MouseEvent e) { // MenuSelectionManager manager = MenuSelectionManager.defaultManager(); // int modifiers = e.getModifiersEx(); // if ((modifiers & InputEvent.BUTTON1_DOWN_MASK) != 0) { // MenuSelectionManager.defaultManager().processMouseEvent(e); // } else { // MenuElement[] path = manager.getSelectedPath(); // if (path.length > 1 && path[path.length - 1] == menuItem) { // MenuElement[] newPath = new MenuElement[path.length - 1]; // System.arraycopy(path, 0, newPath, 0, path.length - 1); // manager.setSelectedPath(newPath); // } // } // } // @Override public void mouseDragged(MouseEvent e) { // MenuSelectionManager.defaultManager().processMouseEvent(e); // } }; }
Example #5
Source File: GtkPaintingUtil.java From consulo with Apache License 2.0 | 4 votes |
public static Color getForeground(final BasicMenuItemUI ui, final JMenuItem menuItem) { final SynthContext context = getSynthContext(ui, menuItem); return context.getStyle().getColor(context, ColorType.TEXT_FOREGROUND); }
Example #6
Source File: GtkMenuItemUI.java From consulo with Apache License 2.0 | 4 votes |
public static boolean isUiAcceptable(final MenuItemUI ui) { return ui instanceof BasicMenuItemUI && GtkPaintingUtil.isSynthUI(ui); }