01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: /**
18: * @author Alexander T. Simbirtsev
19: * @version $Revision$
20: */package javax.swing.plaf.basic;
21:
22: import javax.swing.JComponent;
23: import javax.swing.JPanel;
24: import javax.swing.LookAndFeel;
25: import javax.swing.plaf.ComponentUI;
26: import javax.swing.plaf.PanelUI;
27:
28: public class BasicPanelUI extends PanelUI {
29:
30: private static BasicPanelUI commonBasicPanelUI;
31:
32: private static final String PROPERTY_PREFIX = "Panel.";
33:
34: /**
35: * Uninstalls all necessary UI properties from the component
36: */
37: public void uninstallUI(final JComponent component) {
38: uninstallDefaults((JPanel) component);
39: }
40:
41: /**
42: * Installs all necessary UI properties on the component
43: */
44: public void installUI(final JComponent component) {
45: installDefaults((JPanel) component);
46: }
47:
48: /**
49: *
50: * Creates <code>BasicPanelUI</code> for component it is an instance
51: * of <code>JPanel</code> class
52: *
53: * @return same <code>BasicPanelUI</code> instance for all <code>JPanel</code>
54: * components
55: */
56: public static ComponentUI createUI(final JComponent component) {
57: if (commonBasicPanelUI == null) {
58: commonBasicPanelUI = new BasicPanelUI();
59: }
60:
61: return commonBasicPanelUI;
62: }
63:
64: protected void uninstallDefaults(final JPanel panel) {
65: LookAndFeel.uninstallBorder(panel);
66: }
67:
68: /**
69: * Installs default properties for given panel
70: */
71: protected void installDefaults(final JPanel panel) {
72: LookAndFeel.installColorsAndFont(panel, PROPERTY_PREFIX
73: + "background", PROPERTY_PREFIX + "foreground",
74: PROPERTY_PREFIX + "font");
75: LookAndFeel.installBorder(panel, PROPERTY_PREFIX + "border");
76: }
77:
78: }
|