author | juh |
Tue, 25 Jun 2013 14:41:46 -0700 | |
changeset 18552 | 005e115dc6ee |
parent 5506 | 202f599c92aa |
child 40128 | e635645d2a8a |
permissions | -rw-r--r-- |
3350
100ac73bfe6e
6864297: Right-to-left oriented JScrollPane is aligned to the wrong direction while resizing the container
malenkov
parents:
diff
changeset
|
1 |
/* |
5506 | 2 |
* Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. |
3350
100ac73bfe6e
6864297: Right-to-left oriented JScrollPane is aligned to the wrong direction while resizing the container
malenkov
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
100ac73bfe6e
6864297: Right-to-left oriented JScrollPane is aligned to the wrong direction while resizing the container
malenkov
parents:
diff
changeset
|
4 |
* |
100ac73bfe6e
6864297: Right-to-left oriented JScrollPane is aligned to the wrong direction while resizing the container
malenkov
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
100ac73bfe6e
6864297: Right-to-left oriented JScrollPane is aligned to the wrong direction while resizing the container
malenkov
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
100ac73bfe6e
6864297: Right-to-left oriented JScrollPane is aligned to the wrong direction while resizing the container
malenkov
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
100ac73bfe6e
6864297: Right-to-left oriented JScrollPane is aligned to the wrong direction while resizing the container
malenkov
parents:
diff
changeset
|
8 |
* |
100ac73bfe6e
6864297: Right-to-left oriented JScrollPane is aligned to the wrong direction while resizing the container
malenkov
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
100ac73bfe6e
6864297: Right-to-left oriented JScrollPane is aligned to the wrong direction while resizing the container
malenkov
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
100ac73bfe6e
6864297: Right-to-left oriented JScrollPane is aligned to the wrong direction while resizing the container
malenkov
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
100ac73bfe6e
6864297: Right-to-left oriented JScrollPane is aligned to the wrong direction while resizing the container
malenkov
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
100ac73bfe6e
6864297: Right-to-left oriented JScrollPane is aligned to the wrong direction while resizing the container
malenkov
parents:
diff
changeset
|
13 |
* accompanied this code). |
100ac73bfe6e
6864297: Right-to-left oriented JScrollPane is aligned to the wrong direction while resizing the container
malenkov
parents:
diff
changeset
|
14 |
* |
100ac73bfe6e
6864297: Right-to-left oriented JScrollPane is aligned to the wrong direction while resizing the container
malenkov
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
100ac73bfe6e
6864297: Right-to-left oriented JScrollPane is aligned to the wrong direction while resizing the container
malenkov
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
100ac73bfe6e
6864297: Right-to-left oriented JScrollPane is aligned to the wrong direction while resizing the container
malenkov
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
100ac73bfe6e
6864297: Right-to-left oriented JScrollPane is aligned to the wrong direction while resizing the container
malenkov
parents:
diff
changeset
|
18 |
* |
5506 | 19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
20 |
* or visit www.oracle.com if you need additional information or have any |
|
21 |
* questions. |
|
3350
100ac73bfe6e
6864297: Right-to-left oriented JScrollPane is aligned to the wrong direction while resizing the container
malenkov
parents:
diff
changeset
|
22 |
*/ |
100ac73bfe6e
6864297: Right-to-left oriented JScrollPane is aligned to the wrong direction while resizing the container
malenkov
parents:
diff
changeset
|
23 |
|
100ac73bfe6e
6864297: Right-to-left oriented JScrollPane is aligned to the wrong direction while resizing the container
malenkov
parents:
diff
changeset
|
24 |
/* |
100ac73bfe6e
6864297: Right-to-left oriented JScrollPane is aligned to the wrong direction while resizing the container
malenkov
parents:
diff
changeset
|
25 |
* @test |
100ac73bfe6e
6864297: Right-to-left oriented JScrollPane is aligned to the wrong direction while resizing the container
malenkov
parents:
diff
changeset
|
26 |
* @bug 6526631 |
100ac73bfe6e
6864297: Right-to-left oriented JScrollPane is aligned to the wrong direction while resizing the container
malenkov
parents:
diff
changeset
|
27 |
* @summary Resizes right-oriented scroll pane |
100ac73bfe6e
6864297: Right-to-left oriented JScrollPane is aligned to the wrong direction while resizing the container
malenkov
parents:
diff
changeset
|
28 |
* @author Sergey Malenkov |
100ac73bfe6e
6864297: Right-to-left oriented JScrollPane is aligned to the wrong direction while resizing the container
malenkov
parents:
diff
changeset
|
29 |
* @library .. |
100ac73bfe6e
6864297: Right-to-left oriented JScrollPane is aligned to the wrong direction while resizing the container
malenkov
parents:
diff
changeset
|
30 |
*/ |
100ac73bfe6e
6864297: Right-to-left oriented JScrollPane is aligned to the wrong direction while resizing the container
malenkov
parents:
diff
changeset
|
31 |
|
3502
821e773cae60
6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
3350
diff
changeset
|
32 |
import java.awt.ComponentOrientation; |
3350
100ac73bfe6e
6864297: Right-to-left oriented JScrollPane is aligned to the wrong direction while resizing the container
malenkov
parents:
diff
changeset
|
33 |
import java.awt.Dimension; |
100ac73bfe6e
6864297: Right-to-left oriented JScrollPane is aligned to the wrong direction while resizing the container
malenkov
parents:
diff
changeset
|
34 |
import javax.swing.JFrame; |
100ac73bfe6e
6864297: Right-to-left oriented JScrollPane is aligned to the wrong direction while resizing the container
malenkov
parents:
diff
changeset
|
35 |
import javax.swing.JScrollBar; |
100ac73bfe6e
6864297: Right-to-left oriented JScrollPane is aligned to the wrong direction while resizing the container
malenkov
parents:
diff
changeset
|
36 |
import javax.swing.JScrollPane; |
100ac73bfe6e
6864297: Right-to-left oriented JScrollPane is aligned to the wrong direction while resizing the container
malenkov
parents:
diff
changeset
|
37 |
import javax.swing.JTextArea; |
100ac73bfe6e
6864297: Right-to-left oriented JScrollPane is aligned to the wrong direction while resizing the container
malenkov
parents:
diff
changeset
|
38 |
import javax.swing.JViewport; |
100ac73bfe6e
6864297: Right-to-left oriented JScrollPane is aligned to the wrong direction while resizing the container
malenkov
parents:
diff
changeset
|
39 |
|
100ac73bfe6e
6864297: Right-to-left oriented JScrollPane is aligned to the wrong direction while resizing the container
malenkov
parents:
diff
changeset
|
40 |
public class Test6526631 { |
100ac73bfe6e
6864297: Right-to-left oriented JScrollPane is aligned to the wrong direction while resizing the container
malenkov
parents:
diff
changeset
|
41 |
|
100ac73bfe6e
6864297: Right-to-left oriented JScrollPane is aligned to the wrong direction while resizing the container
malenkov
parents:
diff
changeset
|
42 |
private static final int COLS = 90; |
100ac73bfe6e
6864297: Right-to-left oriented JScrollPane is aligned to the wrong direction while resizing the container
malenkov
parents:
diff
changeset
|
43 |
private static final int ROWS = 50; |
100ac73bfe6e
6864297: Right-to-left oriented JScrollPane is aligned to the wrong direction while resizing the container
malenkov
parents:
diff
changeset
|
44 |
private static final int OFFSET = 10; |
100ac73bfe6e
6864297: Right-to-left oriented JScrollPane is aligned to the wrong direction while resizing the container
malenkov
parents:
diff
changeset
|
45 |
|
3502
821e773cae60
6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
3350
diff
changeset
|
46 |
public static void main(String[] args) throws Throwable { |
3350
100ac73bfe6e
6864297: Right-to-left oriented JScrollPane is aligned to the wrong direction while resizing the container
malenkov
parents:
diff
changeset
|
47 |
SwingTest.start(Test6526631.class); |
100ac73bfe6e
6864297: Right-to-left oriented JScrollPane is aligned to the wrong direction while resizing the container
malenkov
parents:
diff
changeset
|
48 |
} |
100ac73bfe6e
6864297: Right-to-left oriented JScrollPane is aligned to the wrong direction while resizing the container
malenkov
parents:
diff
changeset
|
49 |
|
100ac73bfe6e
6864297: Right-to-left oriented JScrollPane is aligned to the wrong direction while resizing the container
malenkov
parents:
diff
changeset
|
50 |
private final JScrollPane pane; |
100ac73bfe6e
6864297: Right-to-left oriented JScrollPane is aligned to the wrong direction while resizing the container
malenkov
parents:
diff
changeset
|
51 |
private final JFrame frame; |
100ac73bfe6e
6864297: Right-to-left oriented JScrollPane is aligned to the wrong direction while resizing the container
malenkov
parents:
diff
changeset
|
52 |
|
100ac73bfe6e
6864297: Right-to-left oriented JScrollPane is aligned to the wrong direction while resizing the container
malenkov
parents:
diff
changeset
|
53 |
public Test6526631(JFrame frame) { |
100ac73bfe6e
6864297: Right-to-left oriented JScrollPane is aligned to the wrong direction while resizing the container
malenkov
parents:
diff
changeset
|
54 |
this.pane = new JScrollPane(new JTextArea(ROWS, COLS)); |
3502
821e773cae60
6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
3350
diff
changeset
|
55 |
this.pane.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); |
3350
100ac73bfe6e
6864297: Right-to-left oriented JScrollPane is aligned to the wrong direction while resizing the container
malenkov
parents:
diff
changeset
|
56 |
this.frame = frame; |
100ac73bfe6e
6864297: Right-to-left oriented JScrollPane is aligned to the wrong direction while resizing the container
malenkov
parents:
diff
changeset
|
57 |
this.frame.add(this.pane); |
100ac73bfe6e
6864297: Right-to-left oriented JScrollPane is aligned to the wrong direction while resizing the container
malenkov
parents:
diff
changeset
|
58 |
} |
100ac73bfe6e
6864297: Right-to-left oriented JScrollPane is aligned to the wrong direction while resizing the container
malenkov
parents:
diff
changeset
|
59 |
|
100ac73bfe6e
6864297: Right-to-left oriented JScrollPane is aligned to the wrong direction while resizing the container
malenkov
parents:
diff
changeset
|
60 |
private void update(int offset) { |
100ac73bfe6e
6864297: Right-to-left oriented JScrollPane is aligned to the wrong direction while resizing the container
malenkov
parents:
diff
changeset
|
61 |
Dimension size = this.frame.getSize(); |
100ac73bfe6e
6864297: Right-to-left oriented JScrollPane is aligned to the wrong direction while resizing the container
malenkov
parents:
diff
changeset
|
62 |
size.width += offset; |
100ac73bfe6e
6864297: Right-to-left oriented JScrollPane is aligned to the wrong direction while resizing the container
malenkov
parents:
diff
changeset
|
63 |
this.frame.setSize(size); |
100ac73bfe6e
6864297: Right-to-left oriented JScrollPane is aligned to the wrong direction while resizing the container
malenkov
parents:
diff
changeset
|
64 |
} |
100ac73bfe6e
6864297: Right-to-left oriented JScrollPane is aligned to the wrong direction while resizing the container
malenkov
parents:
diff
changeset
|
65 |
|
100ac73bfe6e
6864297: Right-to-left oriented JScrollPane is aligned to the wrong direction while resizing the container
malenkov
parents:
diff
changeset
|
66 |
public void validateFirst() { |
100ac73bfe6e
6864297: Right-to-left oriented JScrollPane is aligned to the wrong direction while resizing the container
malenkov
parents:
diff
changeset
|
67 |
validateThird(); |
100ac73bfe6e
6864297: Right-to-left oriented JScrollPane is aligned to the wrong direction while resizing the container
malenkov
parents:
diff
changeset
|
68 |
update(OFFSET); |
100ac73bfe6e
6864297: Right-to-left oriented JScrollPane is aligned to the wrong direction while resizing the container
malenkov
parents:
diff
changeset
|
69 |
} |
100ac73bfe6e
6864297: Right-to-left oriented JScrollPane is aligned to the wrong direction while resizing the container
malenkov
parents:
diff
changeset
|
70 |
|
100ac73bfe6e
6864297: Right-to-left oriented JScrollPane is aligned to the wrong direction while resizing the container
malenkov
parents:
diff
changeset
|
71 |
public void validateSecond() { |
100ac73bfe6e
6864297: Right-to-left oriented JScrollPane is aligned to the wrong direction while resizing the container
malenkov
parents:
diff
changeset
|
72 |
validateThird(); |
100ac73bfe6e
6864297: Right-to-left oriented JScrollPane is aligned to the wrong direction while resizing the container
malenkov
parents:
diff
changeset
|
73 |
update(-OFFSET); |
100ac73bfe6e
6864297: Right-to-left oriented JScrollPane is aligned to the wrong direction while resizing the container
malenkov
parents:
diff
changeset
|
74 |
} |
100ac73bfe6e
6864297: Right-to-left oriented JScrollPane is aligned to the wrong direction while resizing the container
malenkov
parents:
diff
changeset
|
75 |
|
100ac73bfe6e
6864297: Right-to-left oriented JScrollPane is aligned to the wrong direction while resizing the container
malenkov
parents:
diff
changeset
|
76 |
public void validateThird() { |
100ac73bfe6e
6864297: Right-to-left oriented JScrollPane is aligned to the wrong direction while resizing the container
malenkov
parents:
diff
changeset
|
77 |
JViewport viewport = this.pane.getViewport(); |
100ac73bfe6e
6864297: Right-to-left oriented JScrollPane is aligned to the wrong direction while resizing the container
malenkov
parents:
diff
changeset
|
78 |
JScrollBar scroller = this.pane.getHorizontalScrollBar(); |
3502
821e773cae60
6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
3350
diff
changeset
|
79 |
if (!scroller.getComponentOrientation().equals(ComponentOrientation.RIGHT_TO_LEFT)) { |
821e773cae60
6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
3350
diff
changeset
|
80 |
throw new Error("unexpected component orientation"); |
3350
100ac73bfe6e
6864297: Right-to-left oriented JScrollPane is aligned to the wrong direction while resizing the container
malenkov
parents:
diff
changeset
|
81 |
} |
100ac73bfe6e
6864297: Right-to-left oriented JScrollPane is aligned to the wrong direction while resizing the container
malenkov
parents:
diff
changeset
|
82 |
int value = scroller.getValue(); |
100ac73bfe6e
6864297: Right-to-left oriented JScrollPane is aligned to the wrong direction while resizing the container
malenkov
parents:
diff
changeset
|
83 |
if (value != 0) { |
3502
821e773cae60
6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
3350
diff
changeset
|
84 |
throw new Error("unexpected scroll value"); |
3350
100ac73bfe6e
6864297: Right-to-left oriented JScrollPane is aligned to the wrong direction while resizing the container
malenkov
parents:
diff
changeset
|
85 |
} |
100ac73bfe6e
6864297: Right-to-left oriented JScrollPane is aligned to the wrong direction while resizing the container
malenkov
parents:
diff
changeset
|
86 |
int extent = viewport.getExtentSize().width; |
100ac73bfe6e
6864297: Right-to-left oriented JScrollPane is aligned to the wrong direction while resizing the container
malenkov
parents:
diff
changeset
|
87 |
if (extent != scroller.getVisibleAmount()) { |
3502
821e773cae60
6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
3350
diff
changeset
|
88 |
throw new Error("unexpected visible amount"); |
3350
100ac73bfe6e
6864297: Right-to-left oriented JScrollPane is aligned to the wrong direction while resizing the container
malenkov
parents:
diff
changeset
|
89 |
} |
100ac73bfe6e
6864297: Right-to-left oriented JScrollPane is aligned to the wrong direction while resizing the container
malenkov
parents:
diff
changeset
|
90 |
int size = viewport.getViewSize().width; |
100ac73bfe6e
6864297: Right-to-left oriented JScrollPane is aligned to the wrong direction while resizing the container
malenkov
parents:
diff
changeset
|
91 |
if (size != scroller.getMaximum()) { |
3502
821e773cae60
6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
3350
diff
changeset
|
92 |
throw new Error("unexpected maximum"); |
3350
100ac73bfe6e
6864297: Right-to-left oriented JScrollPane is aligned to the wrong direction while resizing the container
malenkov
parents:
diff
changeset
|
93 |
} |
100ac73bfe6e
6864297: Right-to-left oriented JScrollPane is aligned to the wrong direction while resizing the container
malenkov
parents:
diff
changeset
|
94 |
int pos = size - extent - value; |
100ac73bfe6e
6864297: Right-to-left oriented JScrollPane is aligned to the wrong direction while resizing the container
malenkov
parents:
diff
changeset
|
95 |
if (pos != viewport.getViewPosition().x) { |
3502
821e773cae60
6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
3350
diff
changeset
|
96 |
throw new Error("unexpected position"); |
3350
100ac73bfe6e
6864297: Right-to-left oriented JScrollPane is aligned to the wrong direction while resizing the container
malenkov
parents:
diff
changeset
|
97 |
} |
100ac73bfe6e
6864297: Right-to-left oriented JScrollPane is aligned to the wrong direction while resizing the container
malenkov
parents:
diff
changeset
|
98 |
} |
100ac73bfe6e
6864297: Right-to-left oriented JScrollPane is aligned to the wrong direction while resizing the container
malenkov
parents:
diff
changeset
|
99 |
} |