1 7 8 package com.sun.java.swing.plaf.windows; 9 10 import java.awt.*; 11 import javax.swing.*; 12 import javax.swing.plaf.*; 13 import javax.swing.plaf.basic.*; 14 15 import com.sun.java.swing.plaf.windows.TMSchema.Part; 16 import com.sun.java.swing.plaf.windows.TMSchema.State; 17 18 19 29 public class WindowsCheckBoxMenuItemUI extends BasicCheckBoxMenuItemUI { 30 31 final WindowsMenuItemUIAccessor accessor = 32 new WindowsMenuItemUIAccessor() { 33 34 public JMenuItem getMenuItem() { 35 return menuItem; 36 } 37 38 public State getState(JMenuItem menuItem) { 39 return WindowsMenuItemUI.getState(this, menuItem); 40 } 41 42 public Part getPart(JMenuItem menuItem) { 43 return WindowsMenuItemUI.getPart(this, menuItem); 44 } 45 }; 46 public static ComponentUI createUI(JComponent b) { 47 return new WindowsCheckBoxMenuItemUI(); 48 } 49 50 @Override 51 protected void paintBackground(Graphics g, JMenuItem menuItem, 52 Color bgColor) { 53 if (WindowsMenuItemUI.isVistaPainting()) { 54 WindowsMenuItemUI.paintBackground(accessor, g, menuItem, bgColor); 55 return; 56 } 57 super.paintBackground(g, menuItem, bgColor); 58 } 59 68 protected void paintText(Graphics g, JMenuItem menuItem, 69 Rectangle textRect, String text) { 70 if (WindowsMenuItemUI.isVistaPainting()) { 71 WindowsMenuItemUI.paintText(accessor, g, menuItem, 72 textRect, text); 73 return; 74 } 75 ButtonModel model = menuItem.getModel(); 76 Color oldColor = g.getColor(); 77 78 if(model.isEnabled() && model.isArmed()) { 79 g.setColor(selectionForeground); } 81 82 WindowsGraphicsUtils.paintText(g, menuItem, textRect, text, 0); 83 84 g.setColor(oldColor); 85 } 86 } 87 88 | Popular Tags |