blob: ea3769c2bc610eef2319a9552ba7691ce7c27785 [file] [log] [blame]
J. Duke319a3b92007-12-01 00:00:00 +00001/*
2 * Copyright 1997-2003 Sun Microsystems, Inc. All Rights Reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Sun designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Sun in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
22 * CA 95054 USA or visit www.sun.com if you need additional information or
23 * have any questions.
24 */
25
26package com.sun.java.swing.plaf.motif;
27
28import javax.swing.*;
29import javax.swing.border.*;
30import javax.swing.plaf.basic.BasicRadioButtonUI;
31
32import javax.swing.plaf.*;
33
34import java.awt.*;
35
36/**
37 * RadioButtonUI implementation for MotifRadioButtonUI
38 * <p>
39 * <strong>Warning:</strong>
40 * Serialized objects of this class will not be compatible with
41 * future Swing releases. The current serialization support is appropriate
42 * for short term storage or RMI between applications running the same
43 * version of Swing. A future release of Swing will provide support for
44 * long term persistence.
45 *
46 * @author Rich Schiavi
47 */
48public class MotifRadioButtonUI extends BasicRadioButtonUI {
49
50 private static final MotifRadioButtonUI motifRadioButtonUI = new MotifRadioButtonUI();
51
52 protected Color focusColor;
53
54 private boolean defaults_initialized = false;
55
56 // ********************************
57 // Create PLAF
58 // ********************************
59 public static ComponentUI createUI(JComponent c) {
60 return motifRadioButtonUI;
61 }
62
63 // ********************************
64 // Install Defaults
65 // ********************************
66 public void installDefaults(AbstractButton b) {
67 super.installDefaults(b);
68 if(!defaults_initialized) {
69 focusColor = UIManager.getColor(getPropertyPrefix() + "focus");
70 defaults_initialized = true;
71 }
72 }
73
74 protected void uninstallDefaults(AbstractButton b) {
75 super.uninstallDefaults(b);
76 defaults_initialized = false;
77 }
78
79 // ********************************
80 // Default Accessors
81 // ********************************
82
83 protected Color getFocusColor() {
84 return focusColor;
85 }
86
87 // ********************************
88 // Paint Methods
89 // ********************************
90 protected void paintFocus(Graphics g, Rectangle t, Dimension d){
91 g.setColor(getFocusColor());
92 g.drawRect(0,0,d.width-1,d.height-1);
93 }
94
95}