public void paintIcon(Component c, Graphics g, int x, int y) { if (WindowsMenuItemUI.isVistaPainting()) { XPStyle xp = XPStyle.getXP(); State state = State.NORMAL; if (c instanceof JMenuItem) { state = ((JMenuItem) c).getModel().isEnabled() ? State.NORMAL : State.DISABLED; } Skin skin = xp.getSkin(c, Part.MP_POPUPSUBMENU); if (WindowsGraphicsUtils.isLeftToRight(c)) { skin.paintSkin(g, x, y, state); } else { Graphics2D g2d = (Graphics2D) g.create(); g2d.translate(x + skin.getWidth(), y); g2d.scale(-1, 1); skin.paintSkin(g2d, 0, 0, state); g2d.dispose(); } } else { g.translate(x, y); if (WindowsGraphicsUtils.isLeftToRight(c)) { g.drawLine(0, 0, 0, 7); g.drawLine(1, 1, 1, 6); g.drawLine(2, 2, 2, 5); g.drawLine(3, 3, 3, 4); } else { g.drawLine(4, 0, 4, 7); g.drawLine(3, 1, 3, 6); g.drawLine(2, 2, 2, 5); g.drawLine(1, 3, 1, 4); } g.translate(-x, -y); } }
public void paint(Graphics g, JComponent c) { Dimension s = c.getSize(); if (WindowsMenuItemUI.isVistaPainting()) { int x = 1; Component parent = c.getParent(); if (parent instanceof JComponent) { Object gutterOffsetObject = ((JComponent) parent).getClientProperty(WindowsPopupMenuUI.GUTTER_OFFSET_KEY); if (gutterOffsetObject instanceof Integer) { /* * gutter offset is in parent's coordinates. * See comment in * WindowsPopupMenuUI.getTextOffset(JComponent) */ x = ((Integer) gutterOffsetObject).intValue() - c.getX(); x += WindowsPopupMenuUI.getGutterWidth(); } } Skin skin = XPStyle.getXP().getSkin(c, Part.MP_POPUPSEPARATOR); int skinHeight = skin.getHeight(); int y = (s.height - skinHeight) / 2; skin.paintSkin(g, x, y, s.width - x - 1, skinHeight, State.NORMAL); } else { int y = s.height / 2; g.setColor(c.getForeground()); g.drawLine(1, y - 1, s.width - 2, y - 1); g.setColor(c.getBackground()); g.drawLine(1, y, s.width - 2, y); } }
public int getIconHeight() { if (WindowsMenuItemUI.isVistaPainting()) { Skin skin = XPStyle.getXP().getSkin(null, Part.MP_POPUPSUBMENU); return skin.getHeight(); } else { return 8; } }