1457N/A/*
2362N/A * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
1457N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
1457N/A *
1457N/A * This code is free software; you can redistribute it and/or modify it
1457N/A * under the terms of the GNU General Public License version 2 only, as
1457N/A * published by the Free Software Foundation.
1457N/A *
1457N/A * This code is distributed in the hope that it will be useful, but WITHOUT
1457N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1457N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
1457N/A * version 2 for more details (a copy is included in the LICENSE file that
1457N/A * accompanied this code).
1457N/A *
1457N/A * You should have received a copy of the GNU General Public License version
1457N/A * 2 along with this work; if not, write to the Free Software Foundation,
1457N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1457N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
1457N/A */
1457N/A
1457N/A/*
1457N/A * @test
1457N/A * @bug 6526631
1457N/A * @summary Resizes right-oriented scroll pane
1457N/A * @author Sergey Malenkov
1457N/A * @library ..
1457N/A */
1457N/A
1555N/Aimport java.awt.ComponentOrientation;
1457N/Aimport java.awt.Dimension;
1457N/Aimport javax.swing.JFrame;
1457N/Aimport javax.swing.JScrollBar;
1457N/Aimport javax.swing.JScrollPane;
1457N/Aimport javax.swing.JTextArea;
1457N/Aimport javax.swing.JViewport;
1457N/A
1457N/Apublic class Test6526631 {
1457N/A
1457N/A private static final int COLS = 90;
1457N/A private static final int ROWS = 50;
1457N/A private static final int OFFSET = 10;
1457N/A
1555N/A public static void main(String[] args) throws Throwable {
1457N/A SwingTest.start(Test6526631.class);
1457N/A }
1457N/A
1457N/A private final JScrollPane pane;
1457N/A private final JFrame frame;
1457N/A
1457N/A public Test6526631(JFrame frame) {
1457N/A this.pane = new JScrollPane(new JTextArea(ROWS, COLS));
1555N/A this.pane.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
1457N/A this.frame = frame;
1457N/A this.frame.add(this.pane);
1457N/A }
1457N/A
1457N/A private void update(int offset) {
1457N/A Dimension size = this.frame.getSize();
1457N/A size.width += offset;
1457N/A this.frame.setSize(size);
1457N/A }
1457N/A
1457N/A public void validateFirst() {
1457N/A validateThird();
1457N/A update(OFFSET);
1457N/A }
1457N/A
1457N/A public void validateSecond() {
1457N/A validateThird();
1457N/A update(-OFFSET);
1457N/A }
1457N/A
1457N/A public void validateThird() {
1457N/A JViewport viewport = this.pane.getViewport();
1457N/A JScrollBar scroller = this.pane.getHorizontalScrollBar();
1555N/A if (!scroller.getComponentOrientation().equals(ComponentOrientation.RIGHT_TO_LEFT)) {
1555N/A throw new Error("unexpected component orientation");
1457N/A }
1457N/A int value = scroller.getValue();
1457N/A if (value != 0) {
1555N/A throw new Error("unexpected scroll value");
1457N/A }
1457N/A int extent = viewport.getExtentSize().width;
1457N/A if (extent != scroller.getVisibleAmount()) {
1555N/A throw new Error("unexpected visible amount");
1457N/A }
1457N/A int size = viewport.getViewSize().width;
1457N/A if (size != scroller.getMaximum()) {
1555N/A throw new Error("unexpected maximum");
1457N/A }
1457N/A int pos = size - extent - value;
1457N/A if (pos != viewport.getViewPosition().x) {
1555N/A throw new Error("unexpected position");
1457N/A }
1457N/A }
1457N/A}