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