Merge from mainline
[official-gcc.git] / libjava / classpath / javax / swing / plaf / metal / MetalScrollPaneUI.java
blobae14af3cae98ddd71deb49c80fd4aeae2b48ccbc
1 /* MetalScrollPaneUI.java
2 Copyright (C) 2005 Free Software Foundation, Inc.
4 This file is part of GNU Classpath.
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.
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.
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.
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.
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. */
39 package javax.swing.plaf.metal;
41 import java.beans.PropertyChangeListener;
43 import javax.swing.JComponent;
44 import javax.swing.JScrollBar;
45 import javax.swing.JScrollPane;
46 import javax.swing.plaf.ComponentUI;
47 import javax.swing.plaf.basic.BasicScrollPaneUI;
49 /**
50 * A UI delegate for the {@link JScrollPane} component.
52 public class MetalScrollPaneUI
53 extends BasicScrollPaneUI
55 /**
56 * Constructs a new instance of <code>MetalScrollPaneUI</code>.
58 public MetalScrollPaneUI()
60 super();
63 /**
64 * Returns a shared instance of <code>MetalScrollPaneUI</code>.
66 * @param component the component for which we return an UI instance
68 * @return A shared instance of <code>MetalScrollPaneUI</code>.
70 public static ComponentUI createUI(JComponent component)
72 return new MetalScrollPaneUI();
75 /**
76 * Configures the specified component appropriate for the look and feel.
77 * This method is invoked when the ComponentUI instance is being installed
78 * as the UI delegate on the specified component. This method should
79 * completely configure the component for the look and feel,
80 * including the following:
81 * 1. Install any default property values for color, fonts, borders,
82 * icons, opacity, etc. on the component. Whenever possible, property
83 * values initialized by the client program should not be overridden.
84 * 2. Install a LayoutManager on the component if necessary.
85 * 3. Create/add any required sub-components to the component.
86 * 4. Create/install event listeners on the component.
87 * 5. Create/install a PropertyChangeListener on the component in order
88 * to detect and respond to component property changes appropriately.
89 * 6. Install keyboard UI (mnemonics, traversal, etc.) on the component.
90 * 7. Initialize any appropriate instance data.
92 * @param c - the component to install the ui on
94 public void installUI(JComponent c)
96 super.installUI(c);
97 JScrollBar hsb = scrollpane.getHorizontalScrollBar();
98 hsb.putClientProperty(MetalScrollBarUI.FREE_STANDING_PROP, Boolean.FALSE);
99 JScrollBar vsb = scrollpane.getVerticalScrollBar();
100 vsb.putClientProperty(MetalScrollBarUI.FREE_STANDING_PROP, Boolean.FALSE);
104 * Reverses configuration which was done on the specified component
105 * during installUI. This method is invoked when this UIComponent
106 * instance is being removed as the UI delegate for the specified
107 * component. This method should undo the configuration performed in
108 * installUI, being careful to leave the JComponent instance in a
109 * clean state (no extraneous listeners, look-and-feel-specific property
110 * objects, etc.). This should include the following:
111 * 1. Remove any UI-set borders from the component.
112 * 2. Remove any UI-set layout managers on the component.
113 * 3. Remove any UI-added sub-components from the component.
114 * 4. Remove any UI-added event/property listeners from the component.
115 * 5. Remove any UI-installed keyboard UI from the component.
116 * 6. Nullify any allocated instance data objects to allow for GC.
118 * @param c - the component to uninstall the ui on
120 public void uninstallUI(JComponent c)
122 JScrollBar hsb = scrollpane.getHorizontalScrollBar();
123 hsb.putClientProperty(MetalScrollBarUI.FREE_STANDING_PROP, null);
124 JScrollBar vsb = scrollpane.getVerticalScrollBar();
125 vsb.putClientProperty(MetalScrollBarUI.FREE_STANDING_PROP, null);
126 super.uninstallUI(c);
130 * Installs listeners on scrollPane
132 * @param scrollPane - the component to install the listeners on
134 public void installListeners(JScrollPane scrollPane)
136 super.installListeners(scrollPane);
140 * Uninstalls listeners on scrollPane
142 * @param scrollPane - the component to uninstall the listeners on
144 public void uninstallListeners(JScrollPane scrollPane)
146 super.uninstallListeners(scrollPane);
150 * TODO
152 * @return TODO
154 protected PropertyChangeListener createScrollBarSwapListener()
156 // FIXME: Anything else to do here?
157 return super.createPropertyChangeListener();