01: /*
02: * @(#)NullTristateCheckBox.java 8/11/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 NullButton
46: * @see NullJideButton
47: * @see NullLabel
48: * @see NullRadioButton
49: */
50: public class NullTristateCheckBox extends TristateCheckBox {
51: public NullTristateCheckBox() {
52: }
53:
54: public NullTristateCheckBox(String text) {
55: super (text);
56: }
57:
58: public NullTristateCheckBox(String text, State initial) {
59: super (text, initial);
60: }
61:
62: public NullTristateCheckBox(String text, Icon icon, State initial) {
63: super (text, icon, initial);
64: }
65:
66: @Override
67: public void updateUI() {
68: super .updateUI();
69: clearAttribute();
70: }
71:
72: private void clearAttribute() {
73: setFont(null);
74: setBackground(null);
75: setForeground(null);
76: }
77: }
|