author | azvegint |
Tue, 09 Sep 2014 16:08:34 +0400 | |
changeset 26737 | 26e9206d1a6e |
parent 25859 | 3317bb8137f4 |
child 31164 | a61c96d50ddd |
permissions | -rw-r--r-- |
2 | 1 |
/* |
26737
26e9206d1a6e
8057770: api/javax_swing/JScrollPane/indexTGF.html#UpdateUI failed with MotifLookAndFeel on all platform
azvegint
parents:
25859
diff
changeset
|
2 |
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. |
2 | 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 |
|
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2 | 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 |
* |
|
5506 | 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 |
|
23 |
* questions. |
|
2 | 24 |
*/ |
25 |
||
26 |
package com.sun.java.swing.plaf.motif; |
|
27 |
||
28 |
import javax.swing.*; |
|
29 |
import javax.swing.border.*; |
|
30 |
import javax.swing.plaf.*; |
|
31 |
import javax.swing.plaf.basic.BasicScrollPaneUI; |
|
32 |
||
33 |
import java.beans.PropertyChangeEvent; |
|
34 |
import java.beans.PropertyChangeListener; |
|
35 |
||
36 |
/** |
|
37 |
* A CDE/Motif L&F implementation of ScrollPaneUI. |
|
38 |
* <p> |
|
39 |
* <strong>Warning:</strong> |
|
40 |
* Serialized objects of this class will not be compatible with |
|
41 |
* future Swing releases. The current serialization support is appropriate |
|
42 |
* for short term storage or RMI between applications running the same |
|
43 |
* version of Swing. A future release of Swing will provide support for |
|
44 |
* long term persistence. |
|
45 |
* |
|
46 |
* @author Hans Muller |
|
47 |
*/ |
|
48 |
public class MotifScrollPaneUI extends BasicScrollPaneUI |
|
49 |
{ |
|
50 |
private final static Border vsbMarginBorderR = new EmptyBorder(0, 4, 0, 0); |
|
51 |
private final static Border vsbMarginBorderL = new EmptyBorder(0, 0, 0, 4); |
|
52 |
private final static Border hsbMarginBorder = new EmptyBorder(4, 0, 0, 0); |
|
53 |
||
54 |
private CompoundBorder vsbBorder; |
|
55 |
private CompoundBorder hsbBorder; |
|
56 |
||
57 |
private PropertyChangeListener propertyChangeHandler; |
|
58 |
||
26737
26e9206d1a6e
8057770: api/javax_swing/JScrollPane/indexTGF.html#UpdateUI failed with MotifLookAndFeel on all platform
azvegint
parents:
25859
diff
changeset
|
59 |
@Override |
2 | 60 |
protected void installListeners(JScrollPane scrollPane) { |
61 |
super.installListeners(scrollPane); |
|
62 |
propertyChangeHandler = createPropertyChangeHandler(); |
|
63 |
scrollPane.addPropertyChangeListener(propertyChangeHandler); |
|
64 |
} |
|
65 |
||
26737
26e9206d1a6e
8057770: api/javax_swing/JScrollPane/indexTGF.html#UpdateUI failed with MotifLookAndFeel on all platform
azvegint
parents:
25859
diff
changeset
|
66 |
@Override |
26e9206d1a6e
8057770: api/javax_swing/JScrollPane/indexTGF.html#UpdateUI failed with MotifLookAndFeel on all platform
azvegint
parents:
25859
diff
changeset
|
67 |
protected void uninstallListeners(JComponent scrollPane) { |
2 | 68 |
super.uninstallListeners(scrollPane); |
69 |
scrollPane.removePropertyChangeListener(propertyChangeHandler); |
|
70 |
} |
|
71 |
||
72 |
private PropertyChangeListener createPropertyChangeHandler() { |
|
73 |
return new PropertyChangeListener() { |
|
26737
26e9206d1a6e
8057770: api/javax_swing/JScrollPane/indexTGF.html#UpdateUI failed with MotifLookAndFeel on all platform
azvegint
parents:
25859
diff
changeset
|
74 |
@Override |
2 | 75 |
public void propertyChange(PropertyChangeEvent e) { |
76 |
String propertyName = e.getPropertyName(); |
|
77 |
||
78 |
if (propertyName.equals("componentOrientation")) { |
|
79 |
JScrollPane pane = (JScrollPane)e.getSource(); |
|
80 |
JScrollBar vsb = pane.getVerticalScrollBar(); |
|
81 |
if (vsb != null && vsbBorder != null && |
|
82 |
vsb.getBorder() == vsbBorder) { |
|
83 |
// The Border on the verticall scrollbar matches |
|
84 |
// what we installed, reset it. |
|
85 |
if (MotifGraphicsUtils.isLeftToRight(pane)) { |
|
86 |
vsbBorder = new CompoundBorder(vsbMarginBorderR, |
|
87 |
vsbBorder.getInsideBorder()); |
|
88 |
} else { |
|
89 |
vsbBorder = new CompoundBorder(vsbMarginBorderL, |
|
90 |
vsbBorder.getInsideBorder()); |
|
91 |
} |
|
92 |
vsb.setBorder(vsbBorder); |
|
93 |
} |
|
94 |
} |
|
95 |
}}; |
|
96 |
} |
|
97 |
||
26737
26e9206d1a6e
8057770: api/javax_swing/JScrollPane/indexTGF.html#UpdateUI failed with MotifLookAndFeel on all platform
azvegint
parents:
25859
diff
changeset
|
98 |
@Override |
2 | 99 |
protected void installDefaults(JScrollPane scrollpane) { |
100 |
super.installDefaults(scrollpane); |
|
101 |
||
102 |
JScrollBar vsb = scrollpane.getVerticalScrollBar(); |
|
103 |
if (vsb != null) { |
|
104 |
if (MotifGraphicsUtils.isLeftToRight(scrollpane)) { |
|
105 |
vsbBorder = new CompoundBorder(vsbMarginBorderR, |
|
106 |
vsb.getBorder()); |
|
107 |
} |
|
108 |
else { |
|
109 |
vsbBorder = new CompoundBorder(vsbMarginBorderL, |
|
110 |
vsb.getBorder()); |
|
111 |
} |
|
112 |
vsb.setBorder(vsbBorder); |
|
113 |
} |
|
114 |
||
115 |
JScrollBar hsb = scrollpane.getHorizontalScrollBar(); |
|
116 |
if (hsb != null) { |
|
117 |
hsbBorder = new CompoundBorder(hsbMarginBorder, hsb.getBorder()); |
|
118 |
hsb.setBorder(hsbBorder); |
|
119 |
} |
|
120 |
} |
|
121 |
||
26737
26e9206d1a6e
8057770: api/javax_swing/JScrollPane/indexTGF.html#UpdateUI failed with MotifLookAndFeel on all platform
azvegint
parents:
25859
diff
changeset
|
122 |
@Override |
2 | 123 |
protected void uninstallDefaults(JScrollPane c) { |
124 |
super.uninstallDefaults(c); |
|
125 |
||
126 |
JScrollBar vsb = scrollpane.getVerticalScrollBar(); |
|
127 |
if (vsb != null) { |
|
128 |
if (vsb.getBorder() == vsbBorder) { |
|
129 |
vsb.setBorder(null); |
|
130 |
} |
|
131 |
vsbBorder = null; |
|
132 |
} |
|
133 |
||
134 |
JScrollBar hsb = scrollpane.getHorizontalScrollBar(); |
|
135 |
if (hsb != null) { |
|
136 |
if (hsb.getBorder() == hsbBorder) { |
|
137 |
hsb.setBorder(null); |
|
138 |
} |
|
139 |
hsbBorder = null; |
|
140 |
} |
|
141 |
} |
|
142 |
||
143 |
||
144 |
public static ComponentUI createUI(JComponent x) { |
|
145 |
return new MotifScrollPaneUI(); |
|
146 |
} |
|
147 |
} |