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