1 |
14 |
jlechner |
/* BasicPanelUI.java --
|
2 |
|
|
Copyright (C) 2002, 2004 Free Software Foundation, Inc.
|
3 |
|
|
|
4 |
|
|
This file is part of GNU Classpath.
|
5 |
|
|
|
6 |
|
|
GNU Classpath is free software; you can redistribute it and/or modify
|
7 |
|
|
it under the terms of the GNU General Public License as published by
|
8 |
|
|
the Free Software Foundation; either version 2, or (at your option)
|
9 |
|
|
any later version.
|
10 |
|
|
|
11 |
|
|
GNU Classpath is distributed in the hope that it will be useful, but
|
12 |
|
|
WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14 |
|
|
General Public License for more details.
|
15 |
|
|
|
16 |
|
|
You should have received a copy of the GNU General Public License
|
17 |
|
|
along with GNU Classpath; see the file COPYING. If not, write to the
|
18 |
|
|
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
19 |
|
|
02110-1301 USA.
|
20 |
|
|
|
21 |
|
|
Linking this library statically or dynamically with other modules is
|
22 |
|
|
making a combined work based on this library. Thus, the terms and
|
23 |
|
|
conditions of the GNU General Public License cover the whole
|
24 |
|
|
combination.
|
25 |
|
|
|
26 |
|
|
As a special exception, the copyright holders of this library give you
|
27 |
|
|
permission to link this library with independent modules to produce an
|
28 |
|
|
executable, regardless of the license terms of these independent
|
29 |
|
|
modules, and to copy and distribute the resulting executable under
|
30 |
|
|
terms of your choice, provided that you also meet, for each linked
|
31 |
|
|
independent module, the terms and conditions of the license of that
|
32 |
|
|
module. An independent module is a module which is not derived from
|
33 |
|
|
or based on this library. If you modify this library, you may extend
|
34 |
|
|
this exception to your version of the library, but you are not
|
35 |
|
|
obligated to do so. If you do not wish to do so, delete this
|
36 |
|
|
exception statement from your version. */
|
37 |
|
|
|
38 |
|
|
|
39 |
|
|
package javax.swing.plaf.basic;
|
40 |
|
|
|
41 |
|
|
import java.beans.PropertyChangeEvent;
|
42 |
|
|
import java.beans.PropertyChangeListener;
|
43 |
|
|
|
44 |
|
|
import javax.swing.JComponent;
|
45 |
|
|
import javax.swing.JRootPane;
|
46 |
|
|
import javax.swing.UIManager;
|
47 |
|
|
import javax.swing.plaf.ComponentUI;
|
48 |
|
|
import javax.swing.plaf.RootPaneUI;
|
49 |
|
|
|
50 |
|
|
public class BasicRootPaneUI extends RootPaneUI
|
51 |
|
|
implements PropertyChangeListener
|
52 |
|
|
{
|
53 |
|
|
public static ComponentUI createUI(JComponent x)
|
54 |
|
|
{
|
55 |
|
|
return new BasicRootPaneUI();
|
56 |
|
|
}
|
57 |
|
|
|
58 |
|
|
public void installUI(JComponent c)
|
59 |
|
|
{
|
60 |
|
|
super.installUI(c);
|
61 |
|
|
if (c instanceof JRootPane)
|
62 |
|
|
{
|
63 |
|
|
JRootPane rp = (JRootPane) c;
|
64 |
|
|
installDefaults(rp);
|
65 |
|
|
installComponents(rp);
|
66 |
|
|
installListeners(rp);
|
67 |
|
|
installKeyboardActions(rp);
|
68 |
|
|
}
|
69 |
|
|
}
|
70 |
|
|
|
71 |
|
|
/**
|
72 |
|
|
* Installs the look and feel defaults for JRootPane.
|
73 |
|
|
*
|
74 |
|
|
* @param rp the root pane to install the defaults to
|
75 |
|
|
*/
|
76 |
|
|
protected void installDefaults(JRootPane rp)
|
77 |
|
|
{
|
78 |
|
|
// Is this ok?
|
79 |
|
|
rp.setBackground(UIManager.getColor("control"));
|
80 |
|
|
}
|
81 |
|
|
|
82 |
|
|
/**
|
83 |
|
|
* Installs additional look and feel components to the root pane.
|
84 |
|
|
*
|
85 |
|
|
* @param rp the root pane to install the components to
|
86 |
|
|
*/
|
87 |
|
|
protected void installComponents(JRootPane rp)
|
88 |
|
|
{
|
89 |
|
|
// All components are initialized in the JRootPane constructor, and since
|
90 |
|
|
// the createXXXPane methods are protected, I see no reasonable way,
|
91 |
|
|
// and no need to initialize them here. This method is here anyway
|
92 |
|
|
// for compatibility and to provide the necessary hooks to subclasses.
|
93 |
|
|
}
|
94 |
|
|
|
95 |
|
|
/**
|
96 |
|
|
* Installs any look and feel specific listeners on the root pane.
|
97 |
|
|
*
|
98 |
|
|
* @param rp the root pane to install the listeners to
|
99 |
|
|
*/
|
100 |
|
|
protected void installListeners(JRootPane rp)
|
101 |
|
|
{
|
102 |
|
|
rp.addPropertyChangeListener(this);
|
103 |
|
|
}
|
104 |
|
|
|
105 |
|
|
/**
|
106 |
|
|
* Installs look and feel keyboard actions on the root pane.
|
107 |
|
|
*
|
108 |
|
|
* @param rp the root pane to install the keyboard actions to
|
109 |
|
|
*/
|
110 |
|
|
protected void installKeyboardActions(JRootPane rp)
|
111 |
|
|
{
|
112 |
|
|
// We currently do not install any keyboard actions here.
|
113 |
|
|
// This method is here anyway for compatibility and to provide
|
114 |
|
|
// the necessary hooks to subclasses.
|
115 |
|
|
}
|
116 |
|
|
|
117 |
|
|
public void propertyChange(PropertyChangeEvent event)
|
118 |
|
|
{
|
119 |
|
|
// TODO: Implement this properly.
|
120 |
|
|
}
|
121 |
|
|
|
122 |
|
|
/**
|
123 |
|
|
* Uninstalls this UI from the root pane. This calls
|
124 |
|
|
* {@link #uninstallDefaults}, {@link #uninstallComponents},
|
125 |
|
|
* {@link #uninstallListeners}, {@link #uninstallKeyboardActions}
|
126 |
|
|
* in this order.
|
127 |
|
|
*
|
128 |
|
|
* @param c the root pane to uninstall the UI from
|
129 |
|
|
*/
|
130 |
|
|
public void uninstallUI(JComponent c)
|
131 |
|
|
{
|
132 |
|
|
super.uninstallUI(c);
|
133 |
|
|
if (c instanceof JRootPane)
|
134 |
|
|
{
|
135 |
|
|
JRootPane rp = (JRootPane) c;
|
136 |
|
|
uninstallDefaults(rp);
|
137 |
|
|
uninstallComponents(rp);
|
138 |
|
|
uninstallListeners(rp);
|
139 |
|
|
uninstallKeyboardActions(rp);
|
140 |
|
|
}
|
141 |
|
|
}
|
142 |
|
|
|
143 |
|
|
/**
|
144 |
|
|
* Uninstalls the look and feel defaults that have been installed in
|
145 |
|
|
* {@link #installDefaults}.
|
146 |
|
|
*
|
147 |
|
|
* @param rp the root pane to uninstall the defaults from
|
148 |
|
|
*/
|
149 |
|
|
protected void uninstallDefaults(JRootPane rp)
|
150 |
|
|
{
|
151 |
|
|
// We do nothing here.
|
152 |
|
|
}
|
153 |
|
|
|
154 |
|
|
/**
|
155 |
|
|
* Uninstalls look and feel components from the root pane.
|
156 |
|
|
*
|
157 |
|
|
* @param rp the root pane to uninstall the components from
|
158 |
|
|
*/
|
159 |
|
|
protected void uninstallComponents(JRootPane rp)
|
160 |
|
|
{
|
161 |
|
|
// We do nothing here.
|
162 |
|
|
}
|
163 |
|
|
|
164 |
|
|
/**
|
165 |
|
|
* Uninstalls any look and feel specific listeners from the root pane.
|
166 |
|
|
*
|
167 |
|
|
* @param rp the root pane to uninstall the listeners from
|
168 |
|
|
*/
|
169 |
|
|
protected void uninstallListeners(JRootPane rp)
|
170 |
|
|
{
|
171 |
|
|
rp.removePropertyChangeListener(this);
|
172 |
|
|
}
|
173 |
|
|
|
174 |
|
|
/**
|
175 |
|
|
* Uninstalls look and feel keyboard actions from the root pane.
|
176 |
|
|
*
|
177 |
|
|
* @param rp the root pane to uninstall the keyboard actions from
|
178 |
|
|
*/
|
179 |
|
|
protected void uninstallKeyboardActions(JRootPane rp)
|
180 |
|
|
{
|
181 |
|
|
// We do nothing here.
|
182 |
|
|
}
|
183 |
|
|
}
|