--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/classes/com/sun/java/swing/plaf/windows/WindowsRadioButtonUI.java Sat Dec 01 00:00:00 2007 +0000
@@ -0,0 +1,121 @@
+/*
+ * Copyright 1997-2003 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+package com.sun.java.swing.plaf.windows;
+
+import javax.swing.plaf.basic.*;
+import javax.swing.*;
+import javax.swing.plaf.*;
+
+import java.awt.*;
+
+
+/**
+ * Windows rendition of the component.
+ * <p>
+ * <strong>Warning:</strong>
+ * Serialized objects of this class will not be compatible with
+ * future Swing releases. The current serialization support is appropriate
+ * for short term storage or RMI between applications running the same
+ * version of Swing. A future release of Swing will provide support for
+ * long term persistence.
+ */
+public class WindowsRadioButtonUI extends BasicRadioButtonUI
+{
+ private static final WindowsRadioButtonUI windowsRadioButtonUI = new WindowsRadioButtonUI();
+
+ protected int dashedRectGapX;
+ protected int dashedRectGapY;
+ protected int dashedRectGapWidth;
+ protected int dashedRectGapHeight;
+
+ protected Color focusColor;
+
+ private boolean initialized = false;
+
+ // ********************************
+ // Create PLAF
+ // ********************************
+ public static ComponentUI createUI(JComponent c) {
+ return windowsRadioButtonUI;
+ }
+
+ // ********************************
+ // Defaults
+ // ********************************
+ public void installDefaults(AbstractButton b) {
+ super.installDefaults(b);
+ if(!initialized) {
+ dashedRectGapX = ((Integer)UIManager.get("Button.dashedRectGapX")).intValue();
+ dashedRectGapY = ((Integer)UIManager.get("Button.dashedRectGapY")).intValue();
+ dashedRectGapWidth = ((Integer)UIManager.get("Button.dashedRectGapWidth")).intValue();
+ dashedRectGapHeight = ((Integer)UIManager.get("Button.dashedRectGapHeight")).intValue();
+ focusColor = UIManager.getColor(getPropertyPrefix() + "focus");
+ initialized = true;
+ }
+ if (XPStyle.getXP() != null) {
+ LookAndFeel.installProperty(b, "rolloverEnabled", Boolean.TRUE);
+ }
+ }
+
+ protected Color getFocusColor() {
+ return focusColor;
+ }
+
+ // ********************************
+ // Paint Methods
+ // ********************************
+
+ /**
+ * Overridden method to render the text without the mnemonic
+ */
+ protected void paintText(Graphics g, AbstractButton b, Rectangle textRect, String text) {
+ WindowsGraphicsUtils.paintText(g, b, textRect, text, getTextShiftOffset());
+ }
+
+
+ protected void paintFocus(Graphics g, Rectangle textRect, Dimension d){
+ g.setColor(getFocusColor());
+ BasicGraphicsUtils.drawDashedRect(g, textRect.x, textRect.y, textRect.width, textRect.height);
+ }
+
+ // ********************************
+ // Layout Methods
+ // ********************************
+ public Dimension getPreferredSize(JComponent c) {
+ Dimension d = super.getPreferredSize(c);
+
+ /* Ensure that the width and height of the button is odd,
+ * to allow for the focus line if focus is painted
+ */
+ AbstractButton b = (AbstractButton)c;
+ if (d != null && b.isFocusPainted()) {
+ if(d.width % 2 == 0) { d.width += 1; }
+ if(d.height % 2 == 0) { d.height += 1; }
+ }
+ return d;
+ }
+
+}