author | malenkov |
Thu, 14 Mar 2013 12:15:17 +0400 | |
changeset 16463 | 9f9632c2aede |
child 20121 | 9b9624c7726f |
permissions | -rw-r--r-- |
16463
9f9632c2aede
8000183: 7163696: JCK Swing interactive test JScrollBarTest0013 fails with Nimbus and GTK L&Fs
malenkov
parents:
diff
changeset
|
1 |
/* |
9f9632c2aede
8000183: 7163696: JCK Swing interactive test JScrollBarTest0013 fails with Nimbus and GTK L&Fs
malenkov
parents:
diff
changeset
|
2 |
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. |
9f9632c2aede
8000183: 7163696: JCK Swing interactive test JScrollBarTest0013 fails with Nimbus and GTK L&Fs
malenkov
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
9f9632c2aede
8000183: 7163696: JCK Swing interactive test JScrollBarTest0013 fails with Nimbus and GTK L&Fs
malenkov
parents:
diff
changeset
|
4 |
* |
9f9632c2aede
8000183: 7163696: JCK Swing interactive test JScrollBarTest0013 fails with Nimbus and GTK L&Fs
malenkov
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
9f9632c2aede
8000183: 7163696: JCK Swing interactive test JScrollBarTest0013 fails with Nimbus and GTK L&Fs
malenkov
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
9f9632c2aede
8000183: 7163696: JCK Swing interactive test JScrollBarTest0013 fails with Nimbus and GTK L&Fs
malenkov
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
9f9632c2aede
8000183: 7163696: JCK Swing interactive test JScrollBarTest0013 fails with Nimbus and GTK L&Fs
malenkov
parents:
diff
changeset
|
8 |
* |
9f9632c2aede
8000183: 7163696: JCK Swing interactive test JScrollBarTest0013 fails with Nimbus and GTK L&Fs
malenkov
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
9f9632c2aede
8000183: 7163696: JCK Swing interactive test JScrollBarTest0013 fails with Nimbus and GTK L&Fs
malenkov
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
9f9632c2aede
8000183: 7163696: JCK Swing interactive test JScrollBarTest0013 fails with Nimbus and GTK L&Fs
malenkov
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
9f9632c2aede
8000183: 7163696: JCK Swing interactive test JScrollBarTest0013 fails with Nimbus and GTK L&Fs
malenkov
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
9f9632c2aede
8000183: 7163696: JCK Swing interactive test JScrollBarTest0013 fails with Nimbus and GTK L&Fs
malenkov
parents:
diff
changeset
|
13 |
* accompanied this code). |
9f9632c2aede
8000183: 7163696: JCK Swing interactive test JScrollBarTest0013 fails with Nimbus and GTK L&Fs
malenkov
parents:
diff
changeset
|
14 |
* |
9f9632c2aede
8000183: 7163696: JCK Swing interactive test JScrollBarTest0013 fails with Nimbus and GTK L&Fs
malenkov
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
9f9632c2aede
8000183: 7163696: JCK Swing interactive test JScrollBarTest0013 fails with Nimbus and GTK L&Fs
malenkov
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
9f9632c2aede
8000183: 7163696: JCK Swing interactive test JScrollBarTest0013 fails with Nimbus and GTK L&Fs
malenkov
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
9f9632c2aede
8000183: 7163696: JCK Swing interactive test JScrollBarTest0013 fails with Nimbus and GTK L&Fs
malenkov
parents:
diff
changeset
|
18 |
* |
9f9632c2aede
8000183: 7163696: JCK Swing interactive test JScrollBarTest0013 fails with Nimbus and GTK L&Fs
malenkov
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
9f9632c2aede
8000183: 7163696: JCK Swing interactive test JScrollBarTest0013 fails with Nimbus and GTK L&Fs
malenkov
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
9f9632c2aede
8000183: 7163696: JCK Swing interactive test JScrollBarTest0013 fails with Nimbus and GTK L&Fs
malenkov
parents:
diff
changeset
|
21 |
* questions. |
9f9632c2aede
8000183: 7163696: JCK Swing interactive test JScrollBarTest0013 fails with Nimbus and GTK L&Fs
malenkov
parents:
diff
changeset
|
22 |
*/ |
9f9632c2aede
8000183: 7163696: JCK Swing interactive test JScrollBarTest0013 fails with Nimbus and GTK L&Fs
malenkov
parents:
diff
changeset
|
23 |
|
9f9632c2aede
8000183: 7163696: JCK Swing interactive test JScrollBarTest0013 fails with Nimbus and GTK L&Fs
malenkov
parents:
diff
changeset
|
24 |
/* |
9f9632c2aede
8000183: 7163696: JCK Swing interactive test JScrollBarTest0013 fails with Nimbus and GTK L&Fs
malenkov
parents:
diff
changeset
|
25 |
* @test |
9f9632c2aede
8000183: 7163696: JCK Swing interactive test JScrollBarTest0013 fails with Nimbus and GTK L&Fs
malenkov
parents:
diff
changeset
|
26 |
* @bug 7163696 |
9f9632c2aede
8000183: 7163696: JCK Swing interactive test JScrollBarTest0013 fails with Nimbus and GTK L&Fs
malenkov
parents:
diff
changeset
|
27 |
* @summary Tests that JScrollBar scrolls to the left |
9f9632c2aede
8000183: 7163696: JCK Swing interactive test JScrollBarTest0013 fails with Nimbus and GTK L&Fs
malenkov
parents:
diff
changeset
|
28 |
* @author Sergey Malenkov |
9f9632c2aede
8000183: 7163696: JCK Swing interactive test JScrollBarTest0013 fails with Nimbus and GTK L&Fs
malenkov
parents:
diff
changeset
|
29 |
*/ |
9f9632c2aede
8000183: 7163696: JCK Swing interactive test JScrollBarTest0013 fails with Nimbus and GTK L&Fs
malenkov
parents:
diff
changeset
|
30 |
|
9f9632c2aede
8000183: 7163696: JCK Swing interactive test JScrollBarTest0013 fails with Nimbus and GTK L&Fs
malenkov
parents:
diff
changeset
|
31 |
import sun.awt.SunToolkit; |
9f9632c2aede
8000183: 7163696: JCK Swing interactive test JScrollBarTest0013 fails with Nimbus and GTK L&Fs
malenkov
parents:
diff
changeset
|
32 |
|
9f9632c2aede
8000183: 7163696: JCK Swing interactive test JScrollBarTest0013 fails with Nimbus and GTK L&Fs
malenkov
parents:
diff
changeset
|
33 |
import java.awt.Dimension; |
9f9632c2aede
8000183: 7163696: JCK Swing interactive test JScrollBarTest0013 fails with Nimbus and GTK L&Fs
malenkov
parents:
diff
changeset
|
34 |
import java.awt.Point; |
9f9632c2aede
8000183: 7163696: JCK Swing interactive test JScrollBarTest0013 fails with Nimbus and GTK L&Fs
malenkov
parents:
diff
changeset
|
35 |
import java.awt.Robot; |
9f9632c2aede
8000183: 7163696: JCK Swing interactive test JScrollBarTest0013 fails with Nimbus and GTK L&Fs
malenkov
parents:
diff
changeset
|
36 |
import java.awt.Toolkit; |
9f9632c2aede
8000183: 7163696: JCK Swing interactive test JScrollBarTest0013 fails with Nimbus and GTK L&Fs
malenkov
parents:
diff
changeset
|
37 |
import java.awt.event.InputEvent; |
9f9632c2aede
8000183: 7163696: JCK Swing interactive test JScrollBarTest0013 fails with Nimbus and GTK L&Fs
malenkov
parents:
diff
changeset
|
38 |
|
9f9632c2aede
8000183: 7163696: JCK Swing interactive test JScrollBarTest0013 fails with Nimbus and GTK L&Fs
malenkov
parents:
diff
changeset
|
39 |
import javax.swing.JFrame; |
9f9632c2aede
8000183: 7163696: JCK Swing interactive test JScrollBarTest0013 fails with Nimbus and GTK L&Fs
malenkov
parents:
diff
changeset
|
40 |
import javax.swing.JScrollBar; |
9f9632c2aede
8000183: 7163696: JCK Swing interactive test JScrollBarTest0013 fails with Nimbus and GTK L&Fs
malenkov
parents:
diff
changeset
|
41 |
import javax.swing.SwingUtilities; |
9f9632c2aede
8000183: 7163696: JCK Swing interactive test JScrollBarTest0013 fails with Nimbus and GTK L&Fs
malenkov
parents:
diff
changeset
|
42 |
import javax.swing.UIManager; |
9f9632c2aede
8000183: 7163696: JCK Swing interactive test JScrollBarTest0013 fails with Nimbus and GTK L&Fs
malenkov
parents:
diff
changeset
|
43 |
import javax.swing.UIManager.LookAndFeelInfo; |
9f9632c2aede
8000183: 7163696: JCK Swing interactive test JScrollBarTest0013 fails with Nimbus and GTK L&Fs
malenkov
parents:
diff
changeset
|
44 |
|
9f9632c2aede
8000183: 7163696: JCK Swing interactive test JScrollBarTest0013 fails with Nimbus and GTK L&Fs
malenkov
parents:
diff
changeset
|
45 |
public class Test7163696 implements Runnable { |
9f9632c2aede
8000183: 7163696: JCK Swing interactive test JScrollBarTest0013 fails with Nimbus and GTK L&Fs
malenkov
parents:
diff
changeset
|
46 |
|
9f9632c2aede
8000183: 7163696: JCK Swing interactive test JScrollBarTest0013 fails with Nimbus and GTK L&Fs
malenkov
parents:
diff
changeset
|
47 |
private static final boolean AUTO = null != System.getProperty("test.src", null); |
9f9632c2aede
8000183: 7163696: JCK Swing interactive test JScrollBarTest0013 fails with Nimbus and GTK L&Fs
malenkov
parents:
diff
changeset
|
48 |
|
9f9632c2aede
8000183: 7163696: JCK Swing interactive test JScrollBarTest0013 fails with Nimbus and GTK L&Fs
malenkov
parents:
diff
changeset
|
49 |
public static void main(String[] args) throws Exception { |
9f9632c2aede
8000183: 7163696: JCK Swing interactive test JScrollBarTest0013 fails with Nimbus and GTK L&Fs
malenkov
parents:
diff
changeset
|
50 |
new Test7163696().test(); |
9f9632c2aede
8000183: 7163696: JCK Swing interactive test JScrollBarTest0013 fails with Nimbus and GTK L&Fs
malenkov
parents:
diff
changeset
|
51 |
} |
9f9632c2aede
8000183: 7163696: JCK Swing interactive test JScrollBarTest0013 fails with Nimbus and GTK L&Fs
malenkov
parents:
diff
changeset
|
52 |
|
9f9632c2aede
8000183: 7163696: JCK Swing interactive test JScrollBarTest0013 fails with Nimbus and GTK L&Fs
malenkov
parents:
diff
changeset
|
53 |
private JScrollBar bar; |
9f9632c2aede
8000183: 7163696: JCK Swing interactive test JScrollBarTest0013 fails with Nimbus and GTK L&Fs
malenkov
parents:
diff
changeset
|
54 |
|
9f9632c2aede
8000183: 7163696: JCK Swing interactive test JScrollBarTest0013 fails with Nimbus and GTK L&Fs
malenkov
parents:
diff
changeset
|
55 |
private void test() throws Exception { |
9f9632c2aede
8000183: 7163696: JCK Swing interactive test JScrollBarTest0013 fails with Nimbus and GTK L&Fs
malenkov
parents:
diff
changeset
|
56 |
Robot robot = new Robot(); |
9f9632c2aede
8000183: 7163696: JCK Swing interactive test JScrollBarTest0013 fails with Nimbus and GTK L&Fs
malenkov
parents:
diff
changeset
|
57 |
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit(); |
9f9632c2aede
8000183: 7163696: JCK Swing interactive test JScrollBarTest0013 fails with Nimbus and GTK L&Fs
malenkov
parents:
diff
changeset
|
58 |
for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { |
9f9632c2aede
8000183: 7163696: JCK Swing interactive test JScrollBarTest0013 fails with Nimbus and GTK L&Fs
malenkov
parents:
diff
changeset
|
59 |
UIManager.setLookAndFeel(info.getClassName()); |
9f9632c2aede
8000183: 7163696: JCK Swing interactive test JScrollBarTest0013 fails with Nimbus and GTK L&Fs
malenkov
parents:
diff
changeset
|
60 |
|
9f9632c2aede
8000183: 7163696: JCK Swing interactive test JScrollBarTest0013 fails with Nimbus and GTK L&Fs
malenkov
parents:
diff
changeset
|
61 |
SwingUtilities.invokeAndWait(this); |
9f9632c2aede
8000183: 7163696: JCK Swing interactive test JScrollBarTest0013 fails with Nimbus and GTK L&Fs
malenkov
parents:
diff
changeset
|
62 |
toolkit.realSync(500); // after creation |
9f9632c2aede
8000183: 7163696: JCK Swing interactive test JScrollBarTest0013 fails with Nimbus and GTK L&Fs
malenkov
parents:
diff
changeset
|
63 |
|
9f9632c2aede
8000183: 7163696: JCK Swing interactive test JScrollBarTest0013 fails with Nimbus and GTK L&Fs
malenkov
parents:
diff
changeset
|
64 |
Point point = this.bar.getLocation(); |
9f9632c2aede
8000183: 7163696: JCK Swing interactive test JScrollBarTest0013 fails with Nimbus and GTK L&Fs
malenkov
parents:
diff
changeset
|
65 |
SwingUtilities.convertPointToScreen(point, this.bar); |
9f9632c2aede
8000183: 7163696: JCK Swing interactive test JScrollBarTest0013 fails with Nimbus and GTK L&Fs
malenkov
parents:
diff
changeset
|
66 |
point.x += this.bar.getWidth() >> 2; |
9f9632c2aede
8000183: 7163696: JCK Swing interactive test JScrollBarTest0013 fails with Nimbus and GTK L&Fs
malenkov
parents:
diff
changeset
|
67 |
point.y += this.bar.getHeight() >> 1; |
9f9632c2aede
8000183: 7163696: JCK Swing interactive test JScrollBarTest0013 fails with Nimbus and GTK L&Fs
malenkov
parents:
diff
changeset
|
68 |
robot.mouseMove(point.x, point.y); |
9f9632c2aede
8000183: 7163696: JCK Swing interactive test JScrollBarTest0013 fails with Nimbus and GTK L&Fs
malenkov
parents:
diff
changeset
|
69 |
robot.mousePress(InputEvent.BUTTON1_MASK); |
9f9632c2aede
8000183: 7163696: JCK Swing interactive test JScrollBarTest0013 fails with Nimbus and GTK L&Fs
malenkov
parents:
diff
changeset
|
70 |
robot.mouseRelease(InputEvent.BUTTON1_MASK); |
9f9632c2aede
8000183: 7163696: JCK Swing interactive test JScrollBarTest0013 fails with Nimbus and GTK L&Fs
malenkov
parents:
diff
changeset
|
71 |
|
9f9632c2aede
8000183: 7163696: JCK Swing interactive test JScrollBarTest0013 fails with Nimbus and GTK L&Fs
malenkov
parents:
diff
changeset
|
72 |
toolkit.realSync(500); // before validation |
9f9632c2aede
8000183: 7163696: JCK Swing interactive test JScrollBarTest0013 fails with Nimbus and GTK L&Fs
malenkov
parents:
diff
changeset
|
73 |
SwingUtilities.invokeAndWait(this); |
9f9632c2aede
8000183: 7163696: JCK Swing interactive test JScrollBarTest0013 fails with Nimbus and GTK L&Fs
malenkov
parents:
diff
changeset
|
74 |
|
9f9632c2aede
8000183: 7163696: JCK Swing interactive test JScrollBarTest0013 fails with Nimbus and GTK L&Fs
malenkov
parents:
diff
changeset
|
75 |
if (this.bar != null) { |
9f9632c2aede
8000183: 7163696: JCK Swing interactive test JScrollBarTest0013 fails with Nimbus and GTK L&Fs
malenkov
parents:
diff
changeset
|
76 |
this.bar = null; // allows to reuse the instance |
9f9632c2aede
8000183: 7163696: JCK Swing interactive test JScrollBarTest0013 fails with Nimbus and GTK L&Fs
malenkov
parents:
diff
changeset
|
77 |
if (AUTO) { // error reporting only for automatic testing |
9f9632c2aede
8000183: 7163696: JCK Swing interactive test JScrollBarTest0013 fails with Nimbus and GTK L&Fs
malenkov
parents:
diff
changeset
|
78 |
throw new Error("TEST FAILED"); |
9f9632c2aede
8000183: 7163696: JCK Swing interactive test JScrollBarTest0013 fails with Nimbus and GTK L&Fs
malenkov
parents:
diff
changeset
|
79 |
} |
9f9632c2aede
8000183: 7163696: JCK Swing interactive test JScrollBarTest0013 fails with Nimbus and GTK L&Fs
malenkov
parents:
diff
changeset
|
80 |
} |
9f9632c2aede
8000183: 7163696: JCK Swing interactive test JScrollBarTest0013 fails with Nimbus and GTK L&Fs
malenkov
parents:
diff
changeset
|
81 |
} |
9f9632c2aede
8000183: 7163696: JCK Swing interactive test JScrollBarTest0013 fails with Nimbus and GTK L&Fs
malenkov
parents:
diff
changeset
|
82 |
} |
9f9632c2aede
8000183: 7163696: JCK Swing interactive test JScrollBarTest0013 fails with Nimbus and GTK L&Fs
malenkov
parents:
diff
changeset
|
83 |
|
9f9632c2aede
8000183: 7163696: JCK Swing interactive test JScrollBarTest0013 fails with Nimbus and GTK L&Fs
malenkov
parents:
diff
changeset
|
84 |
public void run() { |
9f9632c2aede
8000183: 7163696: JCK Swing interactive test JScrollBarTest0013 fails with Nimbus and GTK L&Fs
malenkov
parents:
diff
changeset
|
85 |
if (this.bar == null) { |
9f9632c2aede
8000183: 7163696: JCK Swing interactive test JScrollBarTest0013 fails with Nimbus and GTK L&Fs
malenkov
parents:
diff
changeset
|
86 |
this.bar = new JScrollBar(JScrollBar.HORIZONTAL, 50, 10, 0, 100); |
9f9632c2aede
8000183: 7163696: JCK Swing interactive test JScrollBarTest0013 fails with Nimbus and GTK L&Fs
malenkov
parents:
diff
changeset
|
87 |
this.bar.setPreferredSize(new Dimension(400, 20)); |
9f9632c2aede
8000183: 7163696: JCK Swing interactive test JScrollBarTest0013 fails with Nimbus and GTK L&Fs
malenkov
parents:
diff
changeset
|
88 |
|
9f9632c2aede
8000183: 7163696: JCK Swing interactive test JScrollBarTest0013 fails with Nimbus and GTK L&Fs
malenkov
parents:
diff
changeset
|
89 |
JFrame frame = new JFrame(); |
9f9632c2aede
8000183: 7163696: JCK Swing interactive test JScrollBarTest0013 fails with Nimbus and GTK L&Fs
malenkov
parents:
diff
changeset
|
90 |
frame.add(this.bar); |
9f9632c2aede
8000183: 7163696: JCK Swing interactive test JScrollBarTest0013 fails with Nimbus and GTK L&Fs
malenkov
parents:
diff
changeset
|
91 |
frame.pack(); |
9f9632c2aede
8000183: 7163696: JCK Swing interactive test JScrollBarTest0013 fails with Nimbus and GTK L&Fs
malenkov
parents:
diff
changeset
|
92 |
frame.setVisible(true); |
9f9632c2aede
8000183: 7163696: JCK Swing interactive test JScrollBarTest0013 fails with Nimbus and GTK L&Fs
malenkov
parents:
diff
changeset
|
93 |
} |
9f9632c2aede
8000183: 7163696: JCK Swing interactive test JScrollBarTest0013 fails with Nimbus and GTK L&Fs
malenkov
parents:
diff
changeset
|
94 |
else if (40 != this.bar.getValue()) { |
9f9632c2aede
8000183: 7163696: JCK Swing interactive test JScrollBarTest0013 fails with Nimbus and GTK L&Fs
malenkov
parents:
diff
changeset
|
95 |
System.out.println("name = " + UIManager.getLookAndFeel().getName()); |
9f9632c2aede
8000183: 7163696: JCK Swing interactive test JScrollBarTest0013 fails with Nimbus and GTK L&Fs
malenkov
parents:
diff
changeset
|
96 |
System.out.println("value = " + this.bar.getValue()); |
9f9632c2aede
8000183: 7163696: JCK Swing interactive test JScrollBarTest0013 fails with Nimbus and GTK L&Fs
malenkov
parents:
diff
changeset
|
97 |
} |
9f9632c2aede
8000183: 7163696: JCK Swing interactive test JScrollBarTest0013 fails with Nimbus and GTK L&Fs
malenkov
parents:
diff
changeset
|
98 |
else { |
9f9632c2aede
8000183: 7163696: JCK Swing interactive test JScrollBarTest0013 fails with Nimbus and GTK L&Fs
malenkov
parents:
diff
changeset
|
99 |
SwingUtilities.getWindowAncestor(this.bar).dispose(); |
9f9632c2aede
8000183: 7163696: JCK Swing interactive test JScrollBarTest0013 fails with Nimbus and GTK L&Fs
malenkov
parents:
diff
changeset
|
100 |
this.bar = null; |
9f9632c2aede
8000183: 7163696: JCK Swing interactive test JScrollBarTest0013 fails with Nimbus and GTK L&Fs
malenkov
parents:
diff
changeset
|
101 |
} |
9f9632c2aede
8000183: 7163696: JCK Swing interactive test JScrollBarTest0013 fails with Nimbus and GTK L&Fs
malenkov
parents:
diff
changeset
|
102 |
} |
9f9632c2aede
8000183: 7163696: JCK Swing interactive test JScrollBarTest0013 fails with Nimbus and GTK L&Fs
malenkov
parents:
diff
changeset
|
103 |
} |