Example #1
0
 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());
   }
 }
Example #2
0
 protected void paintText(Graphics g, JMenuItem menuItem, Rectangle textRect, String text) {
   Graphics2D g2D = (Graphics2D) g;
   Object savedRenderingHint = null;
   if (AbstractLookAndFeel.getTheme().isTextAntiAliasingOn()) {
     savedRenderingHint = g2D.getRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING);
     g2D.setRenderingHint(
         RenderingHints.KEY_TEXT_ANTIALIASING,
         AbstractLookAndFeel.getTheme().getTextAntiAliasingHint());
   }
   if (menuItem.isSelected() && menuItem.isArmed()) {
     g.setColor(AbstractLookAndFeel.getMenuSelectionForegroundColor());
   } else {
     g.setColor(AbstractLookAndFeel.getMenuForegroundColor());
   }
   super.paintText(g, menuItem, textRect, text);
   if (AbstractLookAndFeel.getTheme().isTextAntiAliasingOn()) {
     g2D.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, savedRenderingHint);
   }
 }