author | alexsch |
Fri, 13 Jan 2012 12:39:23 +0400 | |
changeset 11500 | 36442b344961 |
child 28071 | 3acb75b8df45 |
permissions | -rw-r--r-- |
11500
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
1 |
/* |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
2 |
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
4 |
* |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
8 |
* |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
13 |
* accompanied this code). |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
14 |
* |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
18 |
* |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
21 |
* questions. |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
22 |
*/ |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
23 |
|
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
24 |
/* |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
25 |
* @test |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
26 |
* @bug 4697612 6244705 |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
27 |
* @author Peter Zhelezniakov |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
28 |
* @library ../../regtesthelpers |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
29 |
* @build Util |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
30 |
* @run main bug4697612 |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
31 |
*/ |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
32 |
import java.io.*; |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
33 |
import java.awt.*; |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
34 |
import java.awt.event.*; |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
35 |
import javax.swing.*; |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
36 |
|
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
37 |
import javax.swing.text.BadLocationException; |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
38 |
import sun.awt.SunToolkit; |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
39 |
|
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
40 |
public class bug4697612 { |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
41 |
|
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
42 |
static final int FRAME_WIDTH = 300; |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
43 |
static final int FRAME_HEIGHT = 300; |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
44 |
static final int FONT_HEIGHT = 16; |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
45 |
private static volatile int frameHeight; |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
46 |
private static volatile int fontHeight; |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
47 |
private static JFrame frame; |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
48 |
private static JTextArea text; |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
49 |
private static JScrollPane scroller; |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
50 |
|
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
51 |
public static void main(String[] args) throws Throwable { |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
52 |
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit(); |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
53 |
Robot robot = new Robot(); |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
54 |
robot.setAutoDelay(100); |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
55 |
|
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
56 |
SwingUtilities.invokeAndWait(new Runnable() { |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
57 |
|
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
58 |
@Override |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
59 |
public void run() { |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
60 |
createAndShowGUI(); |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
61 |
} |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
62 |
}); |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
63 |
|
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
64 |
toolkit.realSync(); |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
65 |
|
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
66 |
SwingUtilities.invokeAndWait(new Runnable() { |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
67 |
|
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
68 |
@Override |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
69 |
public void run() { |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
70 |
text.requestFocus(); |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
71 |
} |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
72 |
}); |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
73 |
|
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
74 |
toolkit.realSync(); |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
75 |
|
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
76 |
// 4697612: pressing PgDn + PgUp should not alter caret position |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
77 |
Util.hitKeys(robot, KeyEvent.VK_HOME); |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
78 |
Util.hitKeys(robot, KeyEvent.VK_PAGE_DOWN); |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
79 |
|
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
80 |
|
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
81 |
int pos0 = getTextCaretPosition(); |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
82 |
int caretHeight = getTextCaretHeight(); |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
83 |
fontHeight = FONT_HEIGHT; |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
84 |
|
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
85 |
// iterate two times, for different (even and odd) font height |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
86 |
for (int i = 0; i < 2; i++) { |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
87 |
|
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
88 |
SwingUtilities.invokeAndWait(new Runnable() { |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
89 |
|
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
90 |
public void run() { |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
91 |
text.setFont(text.getFont().deriveFont(fontHeight)); |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
92 |
} |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
93 |
}); |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
94 |
|
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
95 |
frameHeight = FRAME_HEIGHT; |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
96 |
|
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
97 |
for (int j = 0; j < caretHeight; j++) { |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
98 |
SwingUtilities.invokeAndWait(new Runnable() { |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
99 |
|
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
100 |
public void run() { |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
101 |
frame.setSize(FRAME_WIDTH, frameHeight); |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
102 |
} |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
103 |
}); |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
104 |
|
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
105 |
toolkit.realSync(); |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
106 |
|
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
107 |
Util.hitKeys(robot, KeyEvent.VK_PAGE_DOWN); |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
108 |
Util.hitKeys(robot, KeyEvent.VK_PAGE_UP); |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
109 |
toolkit.realSync(); |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
110 |
|
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
111 |
int pos = getTextCaretPosition(); |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
112 |
if (pos0 != pos) { |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
113 |
throw new RuntimeException("Failed 4697612: PgDn & PgUp keys scroll by different amounts"); |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
114 |
} |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
115 |
frameHeight++; |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
116 |
} |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
117 |
fontHeight++; |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
118 |
} |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
119 |
|
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
120 |
|
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
121 |
// 6244705: pressing PgDn at the very bottom should not scroll |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
122 |
LookAndFeel laf = UIManager.getLookAndFeel(); |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
123 |
if (laf.getID().equals("Aqua")) { |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
124 |
Util.hitKeys(robot, KeyEvent.VK_END); |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
125 |
} else { |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
126 |
Util.hitKeys(robot, KeyEvent.VK_CONTROL, KeyEvent.VK_END); |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
127 |
} |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
128 |
|
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
129 |
toolkit.realSync(); |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
130 |
|
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
131 |
pos0 = getScrollerViewPosition(); |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
132 |
Util.hitKeys(robot, KeyEvent.VK_PAGE_DOWN); |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
133 |
toolkit.realSync(); |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
134 |
|
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
135 |
int pos = getScrollerViewPosition(); |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
136 |
|
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
137 |
if (pos0 != pos) { |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
138 |
throw new RuntimeException("Failed 6244705: PgDn at the bottom causes scrolling"); |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
139 |
} |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
140 |
} |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
141 |
|
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
142 |
private static int getTextCaretPosition() throws Exception { |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
143 |
final int[] result = new int[1]; |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
144 |
SwingUtilities.invokeAndWait(new Runnable() { |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
145 |
|
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
146 |
@Override |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
147 |
public void run() { |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
148 |
result[0] = text.getCaretPosition(); |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
149 |
} |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
150 |
}); |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
151 |
|
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
152 |
return result[0]; |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
153 |
} |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
154 |
|
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
155 |
private static int getTextCaretHeight() throws Exception { |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
156 |
final int[] result = new int[1]; |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
157 |
SwingUtilities.invokeAndWait(new Runnable() { |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
158 |
|
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
159 |
@Override |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
160 |
public void run() { |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
161 |
try { |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
162 |
int pos0 = text.getCaretPosition(); |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
163 |
Rectangle dotBounds = text.modelToView(pos0); |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
164 |
result[0] = dotBounds.height; |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
165 |
} catch (BadLocationException ex) { |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
166 |
throw new RuntimeException(ex); |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
167 |
} |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
168 |
} |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
169 |
}); |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
170 |
|
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
171 |
return result[0]; |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
172 |
} |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
173 |
|
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
174 |
private static int getScrollerViewPosition() throws Exception { |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
175 |
final int[] result = new int[1]; |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
176 |
SwingUtilities.invokeAndWait(new Runnable() { |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
177 |
|
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
178 |
@Override |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
179 |
public void run() { |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
180 |
result[0] = scroller.getViewport().getViewPosition().y; |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
181 |
} |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
182 |
}); |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
183 |
|
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
184 |
return result[0]; |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
185 |
} |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
186 |
|
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
187 |
private static void createAndShowGUI() { |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
188 |
frame = new JFrame(); |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
189 |
frame.setSize(FRAME_WIDTH, FRAME_HEIGHT); |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
190 |
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
191 |
|
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
192 |
text = new JTextArea(); |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
193 |
try { |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
194 |
InputStream is = |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
195 |
bug4697612.class.getResourceAsStream("bug4697612.txt"); |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
196 |
text.read(new InputStreamReader(is), null); |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
197 |
} catch (IOException e) { |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
198 |
throw new Error(e); |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
199 |
} |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
200 |
|
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
201 |
scroller = new JScrollPane(text); |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
202 |
|
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
203 |
frame.getContentPane().add(scroller); |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
204 |
|
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
205 |
frame.pack(); |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
206 |
frame.setVisible(true); |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
207 |
} |
36442b344961
7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff
changeset
|
208 |
} |