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 28 public class WindowsRadioButtonMenuItemUI extends BasicRadioButtonMenuItemUI { 29 30 final WindowsMenuItemUIAccessor accessor = 31 new WindowsMenuItemUIAccessor() { 32 33 public JMenuItem getMenuItem() { 34 return menuItem; 35 } 36 37 public State getState(JMenuItem menuItem) { 38 return WindowsMenuItemUI.getState(this, menuItem); 39 } 40 41 public Part getPart(JMenuItem menuItem) { 42 return WindowsMenuItemUI.getPart(this, menuItem); 43 } 44 }; 45 public static ComponentUI createUI(JComponent b) { 46 return new WindowsRadioButtonMenuItemUI(); 47 } 48 49 @Override 50 protected void paintBackground(Graphics g, JMenuItem menuItem, 51 Color bgColor) { 52 if (WindowsMenuItemUI.isVistaPainting()) { 53 WindowsMenuItemUI.paintBackground(accessor, g, menuItem, bgColor); 54 return; 55 } 56 super.paintBackground(g, menuItem, bgColor); 57 } 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, textRect, text); 72 return; 73 } 74 ButtonModel model = menuItem.getModel(); 75 Color oldColor = g.getColor(); 76 77 if(model.isEnabled() && model.isArmed()) { 78 g.setColor(selectionForeground); } 80 81 WindowsGraphicsUtils.paintText(g, menuItem, textRect, text, 0); 82 83 g.setColor(oldColor); 84 } 85 } 86 87 | Popular Tags |