1 30 31 package com.jgoodies.looks.plastic; 32 33 import java.awt.Color ; 34 import java.awt.Graphics ; 35 36 import javax.swing.Icon ; 37 import javax.swing.JComponent ; 38 import javax.swing.JMenu ; 39 import javax.swing.JMenuItem ; 40 import javax.swing.plaf.ComponentUI ; 41 42 import com.jgoodies.looks.common.ExtBasicMenuUI; 43 44 55 public final class PlasticMenuUI extends ExtBasicMenuUI { 56 57 public static ComponentUI createUI(JComponent b) { 58 return new PlasticMenuUI(); 59 } 60 61 62 65 protected void paintMenuItem(Graphics g, JComponent c, Icon aCheckIcon, 66 Icon anArrowIcon, Color background, Color foreground, int textIconGap) { 67 JMenuItem b = (JMenuItem ) c; 68 69 if (((JMenu ) menuItem).isTopLevelMenu()) { 70 b.setOpaque(false); 71 if (b.getModel().isSelected()) { 72 int menuWidth = menuItem.getWidth(); 73 int menuHeight = menuItem.getHeight(); 74 Color oldColor = g.getColor(); 75 g.setColor(background); 76 g.fillRect(0, 0, menuWidth, menuHeight); 77 g.setColor(oldColor); 78 } 79 } 80 super.paintMenuItem(g, c, aCheckIcon, anArrowIcon, background, foreground, textIconGap); 81 } 82 83 84 } | Popular Tags |