38 |
|
|
39 |
package javax.swing.plaf.metal; |
package javax.swing.plaf.metal; |
40 |
|
|
41 |
|
import java.beans.PropertyChangeListener; |
42 |
|
|
43 |
import javax.swing.JComponent; |
import javax.swing.JComponent; |
44 |
|
import javax.swing.JScrollBar; |
45 |
import javax.swing.JScrollPane; |
import javax.swing.JScrollPane; |
46 |
import javax.swing.plaf.ComponentUI; |
import javax.swing.plaf.ComponentUI; |
47 |
import javax.swing.plaf.basic.BasicScrollPaneUI; |
import javax.swing.plaf.basic.BasicScrollPaneUI; |
71 |
{ |
{ |
72 |
return new MetalScrollPaneUI(); |
return new MetalScrollPaneUI(); |
73 |
} |
} |
74 |
|
|
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. |
91 |
|
* |
92 |
|
* @param c - the component to install the ui on |
93 |
|
*/ |
94 |
|
public void installUI(JComponent c) |
95 |
|
{ |
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); |
101 |
|
} |
102 |
|
|
103 |
|
/** |
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. |
117 |
|
* |
118 |
|
* @param c - the component to uninstall the ui on |
119 |
|
*/ |
120 |
|
public void uninstallUI(JComponent c) |
121 |
|
{ |
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); |
127 |
|
} |
128 |
|
|
129 |
|
/** |
130 |
|
* Installs listeners on scrollPane |
131 |
|
* |
132 |
|
* @param scrollPane - the component to install the listeners on |
133 |
|
*/ |
134 |
|
public void installListeners(JScrollPane scrollPane) |
135 |
|
{ |
136 |
|
super.installListeners(scrollPane); |
137 |
|
} |
138 |
|
|
139 |
|
/** |
140 |
|
* Uninstalls listeners on scrollPane |
141 |
|
* |
142 |
|
* @param scrollPane - the component to uninstall the listeners on |
143 |
|
*/ |
144 |
|
public void uninstallListeners(JScrollPane scrollPane) |
145 |
|
{ |
146 |
|
super.uninstallListeners(scrollPane); |
147 |
|
} |
148 |
|
|
149 |
|
/** |
150 |
|
* TODO |
151 |
|
* |
152 |
|
* @return TODO |
153 |
|
*/ |
154 |
|
protected PropertyChangeListener createScrollBarSwapListener() |
155 |
|
{ |
156 |
|
// FIXME: Anything else to do here? |
157 |
|
return super.createPropertyChangeListener(); |
158 |
|
} |
159 |
} |
} |