01: /*
02: * @(#)NullRadioButton.java 7/30/2005
03: *
04: * Copyright 2002 - 2005 JIDE Software Inc. All rights reserved.
05: */
06: package com.jidesoft.swing;
07:
08: import javax.swing.*;
09:
10: /**
11: * This is part of the null-components. A null component doesn't have
12: * foreground, background or font value set. In the other words, the
13: * foreground, background and font value of null-component are null.
14: * But this doesn't mean getBackground(), getForeground() or getFont()
15: * will return null. According to {@link java.awt.Component#getBackground()},
16: * {@link java.awt.Component#getForeground()} and {@link java.awt.Component#getFont()},
17: * if the value is null, it will get the value from its parent.
18: * In the other words, if you add a null-component to JPanel, you can use
19: * JPanel to control the background, foreground and font of this null-component.
20: * The feature is very helpful if you want to make sure all components in a JPanel
21: * has the same background, foreground or font.
22: * <p/>
23: * We creates a few null-components. It doesn't cover all components. You can always
24: * create your own. All you need to do is this
25: * <pre><code>
26: * public class NullXxxComponent extends XxxComponent {
27: * // all the constructors
28: * <p/>
29: * public void updateUI() {
30: * super.updateUI();
31: * clearAttribute();
32: * }
33: * <p/>
34: * private void clearAttribute() {
35: * setFont(null);
36: * setBackground(null);
37: * // do not do this for JButton since JButton always paints button
38: * // content background. So it'd better to leave the foreground alone
39: * setForeground(null);
40: * }
41: * }
42: * </code></pre>
43: *
44: * @see NullPanel
45: * @see NullCheckBox
46: * @see NullJideButton
47: * @see NullLabel
48: * @see NullButton
49: */
50: public class NullRadioButton extends JRadioButton {
51: public NullRadioButton() {
52: }
53:
54: public NullRadioButton(Icon icon) {
55: super (icon);
56: }
57:
58: public NullRadioButton(Action a) {
59: super (a);
60: }
61:
62: public NullRadioButton(Icon icon, boolean selected) {
63: super (icon, selected);
64: }
65:
66: public NullRadioButton(String text) {
67: super (text);
68: }
69:
70: public NullRadioButton(String text, boolean selected) {
71: super (text, selected);
72: }
73:
74: public NullRadioButton(String text, Icon icon) {
75: super (text, icon);
76: }
77:
78: public NullRadioButton(String text, Icon icon, boolean selected) {
79: super (text, icon, selected);
80: }
81:
82: @Override
83: public void updateUI() {
84: super .updateUI();
85: clearAttribute();
86: }
87:
88: private void clearAttribute() {
89: setFont(null);
90: setBackground(null);
91: setForeground(null);
92: }
93: }
|