1 7 8 package com.sun.java.swing.plaf.windows; 9 10 import javax.swing.plaf.basic.*; 11 import javax.swing.*; 12 import javax.swing.plaf.*; 13 14 import java.awt.*; 15 16 17 27 public class WindowsRadioButtonUI extends BasicRadioButtonUI 28 { 29 private static final WindowsRadioButtonUI windowsRadioButtonUI = new WindowsRadioButtonUI(); 30 31 protected int dashedRectGapX; 32 protected int dashedRectGapY; 33 protected int dashedRectGapWidth; 34 protected int dashedRectGapHeight; 35 36 protected Color focusColor; 37 38 private boolean initialized = false; 39 40 public static ComponentUI createUI(JComponent c) { 44 return windowsRadioButtonUI; 45 } 46 47 public void installDefaults(AbstractButton b) { 51 super.installDefaults(b); 52 if(!initialized) { 53 dashedRectGapX = ((Integer )UIManager.get("Button.dashedRectGapX")).intValue(); 54 dashedRectGapY = ((Integer )UIManager.get("Button.dashedRectGapY")).intValue(); 55 dashedRectGapWidth = ((Integer )UIManager.get("Button.dashedRectGapWidth")).intValue(); 56 dashedRectGapHeight = ((Integer )UIManager.get("Button.dashedRectGapHeight")).intValue(); 57 focusColor = UIManager.getColor(getPropertyPrefix() + "focus"); 58 initialized = true; 59 } 60 if (XPStyle.getXP() != null) { 61 LookAndFeel.installProperty(b, "rolloverEnabled", Boolean.TRUE); 62 } 63 } 64 65 protected Color getFocusColor() { 66 return focusColor; 67 } 68 69 73 76 protected void paintText(Graphics g, AbstractButton b, Rectangle textRect, String text) { 77 WindowsGraphicsUtils.paintText(g, b, textRect, text, getTextShiftOffset()); 78 } 79 80 81 protected void paintFocus(Graphics g, Rectangle textRect, Dimension d){ 82 g.setColor(getFocusColor()); 83 BasicGraphicsUtils.drawDashedRect(g, textRect.x, textRect.y, textRect.width, textRect.height); 84 } 85 86 public Dimension getPreferredSize(JComponent c) { 90 Dimension d = super.getPreferredSize(c); 91 92 95 AbstractButton b = (AbstractButton)c; 96 if (d != null && b.isFocusPainted()) { 97 if(d.width % 2 == 0) { d.width += 1; } 98 if(d.height % 2 == 0) { d.height += 1; } 99 } 100 return d; 101 } 102 103 } 104 105 | Popular Tags |