1 /*
2 * Copyright (c) 1997, 2014, Oracle and/or its affiliates. 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. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
44 import javax.swing.border.EmptyBorder;
45 import sun.swing.DefaultLookup;
46
47 /**
48 * Displays an entry in a tree.
49 * <code>DefaultTreeCellRenderer</code> is not opaque and
50 * unless you subclass paint you should not change this.
51 * See <a
52 href="http://docs.oracle.com/javase/tutorial/uiswing/components/tree.html">How to Use Trees</a>
53 * in <em>The Java Tutorial</em>
54 * for examples of customizing node display using this class.
55 * <p>
56 * The set of icons and colors used by {@code DefaultTreeCellRenderer}
57 * can be configured using the various setter methods. The value for
58 * each property is initialized from the defaults table. When the
59 * look and feel changes ({@code updateUI} is invoked), any properties
60 * that have a value of type {@code UIResource} are refreshed from the
61 * defaults table. The following table lists the mapping between
62 * {@code DefaultTreeCellRenderer} property and defaults table key:
63 * <table border="1" cellpadding="1" cellspacing="0" summary="">
64 * <tr valign="top" align="left">
65 * <th style="background-color:#CCCCFF" align="left">Property:
66 * <th style="background-color:#CCCCFF" align="left">Key:
67 * <tr><td>"leafIcon"<td>"Tree.leafIcon"
68 * <tr><td>"closedIcon"<td>"Tree.closedIcon"
69 * <tr><td>"openIcon"<td>"Tree.openIcon"
70 * <tr><td>"textSelectionColor"<td>"Tree.selectionForeground"
71 * <tr><td>"textNonSelectionColor"<td>"Tree.textForeground"
72 * <tr><td>"backgroundSelectionColor"<td>"Tree.selectionBackground"
73 * <tr><td>"backgroundNonSelectionColor"<td>"Tree.textBackground"
74 * <tr><td>"borderSelectionColor"<td>"Tree.selectionBorderColor"
75 * </table>
76 * <p>
77 * <strong><a name="override">Implementation Note:</a></strong>
78 * This class overrides
79 * <code>invalidate</code>,
80 * <code>validate</code>,
81 * <code>revalidate</code>,
82 * <code>repaint</code>,
83 * and
84 * <code>firePropertyChange</code>
85 * solely to improve performance.
86 * If not overridden, these frequently called methods would execute code paths
87 * that are unnecessary for the default tree cell renderer.
88 * If you write your own renderer,
89 * take care to weigh the benefits and
90 * drawbacks of overriding these methods.
91 *
92 * <p>
93 * <strong>Warning:</strong>
94 * Serialized objects of this class will not be compatible with
95 * future Swing releases. The current serialization support is
96 * appropriate for short term storage or RMI between applications running
97 * the same version of Swing. As of 1.4, support for long term storage
|
1 /*
2 * Copyright (c) 1997, 2017, Oracle and/or its affiliates. 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. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
44 import javax.swing.border.EmptyBorder;
45 import sun.swing.DefaultLookup;
46
47 /**
48 * Displays an entry in a tree.
49 * <code>DefaultTreeCellRenderer</code> is not opaque and
50 * unless you subclass paint you should not change this.
51 * See <a
52 href="http://docs.oracle.com/javase/tutorial/uiswing/components/tree.html">How to Use Trees</a>
53 * in <em>The Java Tutorial</em>
54 * for examples of customizing node display using this class.
55 * <p>
56 * The set of icons and colors used by {@code DefaultTreeCellRenderer}
57 * can be configured using the various setter methods. The value for
58 * each property is initialized from the defaults table. When the
59 * look and feel changes ({@code updateUI} is invoked), any properties
60 * that have a value of type {@code UIResource} are refreshed from the
61 * defaults table. The following table lists the mapping between
62 * {@code DefaultTreeCellRenderer} property and defaults table key:
63 * <table border="1" cellpadding="1" cellspacing="0" summary="">
64 * <tr valign="top" style="text-align:left">
65 * <th style="background-color:#CCCCFF;text-align:left">Property:
66 * <th style="background-color:#CCCCFF;text-align:left">Key:
67 * <tr><td>"leafIcon"<td>"Tree.leafIcon"
68 * <tr><td>"closedIcon"<td>"Tree.closedIcon"
69 * <tr><td>"openIcon"<td>"Tree.openIcon"
70 * <tr><td>"textSelectionColor"<td>"Tree.selectionForeground"
71 * <tr><td>"textNonSelectionColor"<td>"Tree.textForeground"
72 * <tr><td>"backgroundSelectionColor"<td>"Tree.selectionBackground"
73 * <tr><td>"backgroundNonSelectionColor"<td>"Tree.textBackground"
74 * <tr><td>"borderSelectionColor"<td>"Tree.selectionBorderColor"
75 * </table>
76 * <p>
77 * <strong><a id="override">Implementation Note:</a></strong>
78 * This class overrides
79 * <code>invalidate</code>,
80 * <code>validate</code>,
81 * <code>revalidate</code>,
82 * <code>repaint</code>,
83 * and
84 * <code>firePropertyChange</code>
85 * solely to improve performance.
86 * If not overridden, these frequently called methods would execute code paths
87 * that are unnecessary for the default tree cell renderer.
88 * If you write your own renderer,
89 * take care to weigh the benefits and
90 * drawbacks of overriding these methods.
91 *
92 * <p>
93 * <strong>Warning:</strong>
94 * Serialized objects of this class will not be compatible with
95 * future Swing releases. The current serialization support is
96 * appropriate for short term storage or RMI between applications running
97 * the same version of Swing. As of 1.4, support for long term storage
|