protected void paintBackground(Graphics g, JComponent c, int x, int y, int w, int h) { JMenuItem b = (JMenuItem) c; ButtonModel model = b.getModel(); if (c.getParent() instanceof JMenuBar) { if (model.isArmed() || (c instanceof JMenu && model.isSelected())) { g.setColor(AbstractLookAndFeel.getMenuSelectionBackgroundColor()); g.fillRect(x, y, w, h); } } else { if (model.isArmed() || (c instanceof JMenu && model.isSelected())) { g.setColor(AbstractLookAndFeel.getMenuSelectionBackgroundColor()); g.fillRect(x, y, w, h); } else if (!AbstractLookAndFeel.getTheme().isMenuOpaque()) { Graphics2D g2D = (Graphics2D) g; Composite composite = g2D.getComposite(); AlphaComposite alpha = AlphaComposite.getInstance( AlphaComposite.SRC_OVER, AbstractLookAndFeel.getTheme().getMenuAlpha()); g2D.setComposite(alpha); g.setColor(AbstractLookAndFeel.getMenuBackgroundColor()); g.fillRect(x, y, w, h); g2D.setComposite(composite); } else { g.setColor(AbstractLookAndFeel.getMenuBackgroundColor()); g.fillRect(x, y, w, h); } } if (menuItem.isSelected() && menuItem.isArmed()) { g.setColor(AbstractLookAndFeel.getMenuSelectionForegroundColor()); } else { g.setColor(AbstractLookAndFeel.getMenuForegroundColor()); } }
public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) { Color logoColor = AbstractLookAndFeel.getMenuSelectionBackgroundColor(); Color borderColorLo = AbstractLookAndFeel.getFrameColor(); Color borderColorHi = ColorHelper.brighter(AbstractLookAndFeel.getMenuSelectionBackgroundColor(), 40); g.setColor(logoColor); if (JTattooUtilities.isLeftToRight(c)) { int dx = getBorderInsets(c).left; g.fillRect(x, y, dx - 1, h - 1); paintLogo(c, g, x, y, w, h); // - highlight g.setColor(ColorHelper.brighter(AbstractLookAndFeel.getMenuBackgroundColor(), 40)); g.drawLine(x + dx, y + 1, x + w - 2, y + 1); g.setColor(borderColorHi); g.drawLine(x + 1, y, x + 1, y + h - 2); // - outer frame g.setColor(borderColorLo); if (isMenuBarPopup(c)) { // top g.drawLine(x + dx - 1, y, x + w, y); // left g.drawLine(x, y, x, y + h - 1); // bottom g.drawLine(x, y + h - 1, x + w, y + h - 1); // right g.drawLine(x + w - 1, y + 1, x + w - 1, y + h - 1); } else { g.drawRect(x, y, w - 1, h - 1); } // - logo separator g.drawLine(x + dx - 1, y + 1, x + dx - 1, y + h - 1); } else { int dx = getBorderInsets(c).right; g.fillRect(x + w - dx, y, dx, h - 1); paintLogo(c, g, x, y, w, h); // - highlight g.setColor(ColorHelper.brighter(AbstractLookAndFeel.getMenuBackgroundColor(), 40)); g.drawLine(x + 1, y + 1, x + w - dx - 1, y + 1); g.drawLine(x + 1, y + 1, x + 1, y + h - 2); // - outer frame g.setColor(borderColorLo); if (isMenuBarPopup(c)) { // top g.drawLine(x, y, x + w - dx, y); // left g.drawLine(x, y, x, y + h - 1); // bottom g.drawLine(x, y + h - 1, x + w, y + h - 1); // right g.drawLine(x + w - 1, y, x + w - 1, y + h - 1); } else { g.drawRect(x, y, w - 1, h - 1); } // - logo separator g.drawLine(x + w - dx, y + 1, x + w - dx, y + h - 1); } }
public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) { JMenuItem b = (JMenuItem) c; ButtonModel model = b.getModel(); Color borderColorLo = AbstractLookAndFeel.getFrameColor(); Color borderColorHi = ColorHelper.brighter(AbstractLookAndFeel.getMenuSelectionBackgroundColor(), 40); if (c.getParent() instanceof JMenuBar) { if (model.isArmed() || model.isSelected()) { g.setColor(borderColorLo); g.drawLine(x, y, x + w - 1, y); g.drawLine(x, y, x, y + h - 1); g.drawLine(x + w - 1, y + 1, x + w - 1, y + h - 1); g.setColor(borderColorHi); g.drawLine(x + 1, y + 1, x + w - 2, y + 1); g.drawLine(x + 1, y + 1, x + 1, y + h - 1); } } else { if (model.isArmed() || (c instanceof JMenu && model.isSelected())) { g.setColor(borderColorLo); g.drawLine(x, y, x + w - 1, y); g.drawLine(x, y + h - 1, x + w - 1, y + h - 1); g.setColor(borderColorHi); g.drawLine(x, y + 1, x + w - 2, y + 1); } } }
public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) { Graphics2D g2D = (Graphics2D) g; Composite savedComposite = g2D.getComposite(); AlphaComposite alpha = AlphaComposite.getInstance( AlphaComposite.SRC_OVER, AbstractLookAndFeel.getTheme().getMenuAlpha()); g2D.setComposite(alpha); Color logoColor = AbstractLookAndFeel.getTheme().getMenuSelectionBackgroundColor(); Color borderColorLo = AbstractLookAndFeel.getFrameColor(); Color borderColorHi = ColorHelper.brighter(AbstractLookAndFeel.getMenuSelectionBackgroundColor(), 40); g.setColor(logoColor); if (JTattooUtilities.isLeftToRight(c)) { int dx = getBorderInsets(c).left; g.fillRect(x, y, dx - 1, h - 1 - shadowSize); paintLogo(c, g, x, y, w, h); // - highlight g.setColor(ColorHelper.brighter(AbstractLookAndFeel.getMenuBackgroundColor(), 40)); g.drawLine(x + dx, y + 1, x + w - shadowSize - 2, y + 1); g.setColor(borderColorHi); g.drawLine(x + 1, y, x + 1, y + h - shadowSize - 2); // - outer frame g.setColor(borderColorLo); if (isMenuBarPopup(c)) { // top g.drawLine(x + dx - 1, y, x + w - shadowSize - 1, y); // left g.drawLine(x, y, x, y + h - shadowSize - 1); // bottom g.drawLine(x, y + h - shadowSize - 1, x + w - shadowSize - 1, y + h - shadowSize - 1); // right g.drawLine(x + w - shadowSize - 1, y + 1, x + w - shadowSize - 1, y + h - shadowSize - 1); } else { g.drawRect(x, y, w - shadowSize - 1, h - shadowSize - 1); } // - logo separator g.drawLine(x + dx - 1, y + 1, x + dx - 1, y + h - shadowSize - 1); } else { int dx = getBorderInsets(c).right - shadowSize; g.fillRect(x + w - dx - shadowSize, y, dx - 1, h - 1 - shadowSize); paintLogo(c, g, x, y, w, h); // - highlight g.setColor(ColorHelper.brighter(AbstractLookAndFeel.getMenuBackgroundColor(), 40)); g.drawLine(x + 1, y + 1, x + w - dx - shadowSize - 1, y + 1); g.drawLine(x + 1, y + 1, x + 1, y + h - shadowSize - 2); // - outer frame g.setColor(borderColorLo); if (isMenuBarPopup(c)) { // top g.drawLine(x, y, x + w - dx - shadowSize, y); // left g.drawLine(x, y, x, y + h - shadowSize - 1); // bottom g.drawLine(x, y + h - shadowSize - 1, x + w - shadowSize - 1, y + h - shadowSize - 1); // right g.drawLine(x + w - shadowSize - 1, y, x + w - shadowSize - 1, y + h - shadowSize - 1); } else { g.drawRect(x, y, w - shadowSize - 1, h - shadowSize - 1); } // - logo separator g.drawLine(x + w - dx - shadowSize, y + 1, x + w - dx - shadowSize, y + h - shadowSize - 1); } // paint the shadow g2D.setColor(AbstractLookAndFeel.getTheme().getShadowColor()); float alphaValue = 0.4f; for (int i = 0; i < shadowSize; i++) { alpha = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alphaValue); g2D.setComposite(alpha); g.drawLine( x + w - shadowSize + i, y + shadowSize, x + w - shadowSize + i, y + h - shadowSize - 1 + i); g.drawLine( x + shadowSize, y + h - shadowSize + i, x + w - shadowSize + i, y + h - shadowSize + i); alphaValue -= (alphaValue / 2); } g2D.setComposite(savedComposite); }