author | ssadetsky |
Tue, 07 Jul 2015 09:51:30 +0300 | |
changeset 31663 | 968cd1d0b646 |
parent 30452 | 9cc90ad7cf9a |
child 46151 | 5fa789776f7d |
permissions | -rw-r--r-- |
30452
9cc90ad7cf9a
6866751: J2SE_Swing_Reg: the caret disappears when moving to the end of the line.
ssadetsky
parents:
diff
changeset
|
1 |
/* |
9cc90ad7cf9a
6866751: J2SE_Swing_Reg: the caret disappears when moving to the end of the line.
ssadetsky
parents:
diff
changeset
|
2 |
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. |
9cc90ad7cf9a
6866751: J2SE_Swing_Reg: the caret disappears when moving to the end of the line.
ssadetsky
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
9cc90ad7cf9a
6866751: J2SE_Swing_Reg: the caret disappears when moving to the end of the line.
ssadetsky
parents:
diff
changeset
|
4 |
* |
9cc90ad7cf9a
6866751: J2SE_Swing_Reg: the caret disappears when moving to the end of the line.
ssadetsky
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
9cc90ad7cf9a
6866751: J2SE_Swing_Reg: the caret disappears when moving to the end of the line.
ssadetsky
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
9cc90ad7cf9a
6866751: J2SE_Swing_Reg: the caret disappears when moving to the end of the line.
ssadetsky
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
9cc90ad7cf9a
6866751: J2SE_Swing_Reg: the caret disappears when moving to the end of the line.
ssadetsky
parents:
diff
changeset
|
8 |
* |
9cc90ad7cf9a
6866751: J2SE_Swing_Reg: the caret disappears when moving to the end of the line.
ssadetsky
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
9cc90ad7cf9a
6866751: J2SE_Swing_Reg: the caret disappears when moving to the end of the line.
ssadetsky
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
9cc90ad7cf9a
6866751: J2SE_Swing_Reg: the caret disappears when moving to the end of the line.
ssadetsky
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
9cc90ad7cf9a
6866751: J2SE_Swing_Reg: the caret disappears when moving to the end of the line.
ssadetsky
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
9cc90ad7cf9a
6866751: J2SE_Swing_Reg: the caret disappears when moving to the end of the line.
ssadetsky
parents:
diff
changeset
|
13 |
* accompanied this code). |
9cc90ad7cf9a
6866751: J2SE_Swing_Reg: the caret disappears when moving to the end of the line.
ssadetsky
parents:
diff
changeset
|
14 |
* |
9cc90ad7cf9a
6866751: J2SE_Swing_Reg: the caret disappears when moving to the end of the line.
ssadetsky
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
9cc90ad7cf9a
6866751: J2SE_Swing_Reg: the caret disappears when moving to the end of the line.
ssadetsky
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
9cc90ad7cf9a
6866751: J2SE_Swing_Reg: the caret disappears when moving to the end of the line.
ssadetsky
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
9cc90ad7cf9a
6866751: J2SE_Swing_Reg: the caret disappears when moving to the end of the line.
ssadetsky
parents:
diff
changeset
|
18 |
* |
9cc90ad7cf9a
6866751: J2SE_Swing_Reg: the caret disappears when moving to the end of the line.
ssadetsky
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
9cc90ad7cf9a
6866751: J2SE_Swing_Reg: the caret disappears when moving to the end of the line.
ssadetsky
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
9cc90ad7cf9a
6866751: J2SE_Swing_Reg: the caret disappears when moving to the end of the line.
ssadetsky
parents:
diff
changeset
|
21 |
* questions. |
9cc90ad7cf9a
6866751: J2SE_Swing_Reg: the caret disappears when moving to the end of the line.
ssadetsky
parents:
diff
changeset
|
22 |
*/ |
9cc90ad7cf9a
6866751: J2SE_Swing_Reg: the caret disappears when moving to the end of the line.
ssadetsky
parents:
diff
changeset
|
23 |
|
9cc90ad7cf9a
6866751: J2SE_Swing_Reg: the caret disappears when moving to the end of the line.
ssadetsky
parents:
diff
changeset
|
24 |
/* @test |
9cc90ad7cf9a
6866751: J2SE_Swing_Reg: the caret disappears when moving to the end of the line.
ssadetsky
parents:
diff
changeset
|
25 |
@bug 6866751 |
9cc90ad7cf9a
6866751: J2SE_Swing_Reg: the caret disappears when moving to the end of the line.
ssadetsky
parents:
diff
changeset
|
26 |
@summary J2SE_Swing_Reg: the caret disappears when moving to the end of the line. |
9cc90ad7cf9a
6866751: J2SE_Swing_Reg: the caret disappears when moving to the end of the line.
ssadetsky
parents:
diff
changeset
|
27 |
@author Semyon Sadetsky |
9cc90ad7cf9a
6866751: J2SE_Swing_Reg: the caret disappears when moving to the end of the line.
ssadetsky
parents:
diff
changeset
|
28 |
*/ |
9cc90ad7cf9a
6866751: J2SE_Swing_Reg: the caret disappears when moving to the end of the line.
ssadetsky
parents:
diff
changeset
|
29 |
import javax.swing.*; |
31663
968cd1d0b646
8081484: [TEST_BUG]Test javax/swing/plaf/basic/6866751/bug6866751.java fails
ssadetsky
parents:
30452
diff
changeset
|
30 |
import java.awt.*; |
30452
9cc90ad7cf9a
6866751: J2SE_Swing_Reg: the caret disappears when moving to the end of the line.
ssadetsky
parents:
diff
changeset
|
31 |
|
9cc90ad7cf9a
6866751: J2SE_Swing_Reg: the caret disappears when moving to the end of the line.
ssadetsky
parents:
diff
changeset
|
32 |
public class bug6866751 { |
9cc90ad7cf9a
6866751: J2SE_Swing_Reg: the caret disappears when moving to the end of the line.
ssadetsky
parents:
diff
changeset
|
33 |
private static JFrame frame; |
9cc90ad7cf9a
6866751: J2SE_Swing_Reg: the caret disappears when moving to the end of the line.
ssadetsky
parents:
diff
changeset
|
34 |
private static JTextArea area; |
9cc90ad7cf9a
6866751: J2SE_Swing_Reg: the caret disappears when moving to the end of the line.
ssadetsky
parents:
diff
changeset
|
35 |
|
9cc90ad7cf9a
6866751: J2SE_Swing_Reg: the caret disappears when moving to the end of the line.
ssadetsky
parents:
diff
changeset
|
36 |
public static void main(String[] args) throws Exception { |
9cc90ad7cf9a
6866751: J2SE_Swing_Reg: the caret disappears when moving to the end of the line.
ssadetsky
parents:
diff
changeset
|
37 |
try { |
9cc90ad7cf9a
6866751: J2SE_Swing_Reg: the caret disappears when moving to the end of the line.
ssadetsky
parents:
diff
changeset
|
38 |
SwingUtilities.invokeAndWait(new Runnable() { |
9cc90ad7cf9a
6866751: J2SE_Swing_Reg: the caret disappears when moving to the end of the line.
ssadetsky
parents:
diff
changeset
|
39 |
public void run() { |
9cc90ad7cf9a
6866751: J2SE_Swing_Reg: the caret disappears when moving to the end of the line.
ssadetsky
parents:
diff
changeset
|
40 |
frame = new JFrame(); |
9cc90ad7cf9a
6866751: J2SE_Swing_Reg: the caret disappears when moving to the end of the line.
ssadetsky
parents:
diff
changeset
|
41 |
frame.setUndecorated(true); |
9cc90ad7cf9a
6866751: J2SE_Swing_Reg: the caret disappears when moving to the end of the line.
ssadetsky
parents:
diff
changeset
|
42 |
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); |
9cc90ad7cf9a
6866751: J2SE_Swing_Reg: the caret disappears when moving to the end of the line.
ssadetsky
parents:
diff
changeset
|
43 |
setup(frame); |
9cc90ad7cf9a
6866751: J2SE_Swing_Reg: the caret disappears when moving to the end of the line.
ssadetsky
parents:
diff
changeset
|
44 |
} |
9cc90ad7cf9a
6866751: J2SE_Swing_Reg: the caret disappears when moving to the end of the line.
ssadetsky
parents:
diff
changeset
|
45 |
}); |
9cc90ad7cf9a
6866751: J2SE_Swing_Reg: the caret disappears when moving to the end of the line.
ssadetsky
parents:
diff
changeset
|
46 |
SwingUtilities.invokeAndWait(new Runnable() { |
9cc90ad7cf9a
6866751: J2SE_Swing_Reg: the caret disappears when moving to the end of the line.
ssadetsky
parents:
diff
changeset
|
47 |
public void run() { |
9cc90ad7cf9a
6866751: J2SE_Swing_Reg: the caret disappears when moving to the end of the line.
ssadetsky
parents:
diff
changeset
|
48 |
int width = area.getWidth(); |
9cc90ad7cf9a
6866751: J2SE_Swing_Reg: the caret disappears when moving to the end of the line.
ssadetsky
parents:
diff
changeset
|
49 |
double caretX = |
9cc90ad7cf9a
6866751: J2SE_Swing_Reg: the caret disappears when moving to the end of the line.
ssadetsky
parents:
diff
changeset
|
50 |
area.getCaret().getMagicCaretPosition().getX(); |
9cc90ad7cf9a
6866751: J2SE_Swing_Reg: the caret disappears when moving to the end of the line.
ssadetsky
parents:
diff
changeset
|
51 |
if (width < caretX + 1) { |
9cc90ad7cf9a
6866751: J2SE_Swing_Reg: the caret disappears when moving to the end of the line.
ssadetsky
parents:
diff
changeset
|
52 |
throw new RuntimeException( |
9cc90ad7cf9a
6866751: J2SE_Swing_Reg: the caret disappears when moving to the end of the line.
ssadetsky
parents:
diff
changeset
|
53 |
"Width of the area (" + width + |
9cc90ad7cf9a
6866751: J2SE_Swing_Reg: the caret disappears when moving to the end of the line.
ssadetsky
parents:
diff
changeset
|
54 |
") is less than caret x-position " + |
9cc90ad7cf9a
6866751: J2SE_Swing_Reg: the caret disappears when moving to the end of the line.
ssadetsky
parents:
diff
changeset
|
55 |
caretX + 1); |
9cc90ad7cf9a
6866751: J2SE_Swing_Reg: the caret disappears when moving to the end of the line.
ssadetsky
parents:
diff
changeset
|
56 |
} |
9cc90ad7cf9a
6866751: J2SE_Swing_Reg: the caret disappears when moving to the end of the line.
ssadetsky
parents:
diff
changeset
|
57 |
area.putClientProperty("caretWidth", 10); |
31663
968cd1d0b646
8081484: [TEST_BUG]Test javax/swing/plaf/basic/6866751/bug6866751.java fails
ssadetsky
parents:
30452
diff
changeset
|
58 |
frame.pack(); |
30452
9cc90ad7cf9a
6866751: J2SE_Swing_Reg: the caret disappears when moving to the end of the line.
ssadetsky
parents:
diff
changeset
|
59 |
} |
9cc90ad7cf9a
6866751: J2SE_Swing_Reg: the caret disappears when moving to the end of the line.
ssadetsky
parents:
diff
changeset
|
60 |
}); |
31663
968cd1d0b646
8081484: [TEST_BUG]Test javax/swing/plaf/basic/6866751/bug6866751.java fails
ssadetsky
parents:
30452
diff
changeset
|
61 |
new Robot().waitForIdle(); |
30452
9cc90ad7cf9a
6866751: J2SE_Swing_Reg: the caret disappears when moving to the end of the line.
ssadetsky
parents:
diff
changeset
|
62 |
SwingUtilities.invokeAndWait(new Runnable() { |
9cc90ad7cf9a
6866751: J2SE_Swing_Reg: the caret disappears when moving to the end of the line.
ssadetsky
parents:
diff
changeset
|
63 |
public void run() { |
9cc90ad7cf9a
6866751: J2SE_Swing_Reg: the caret disappears when moving to the end of the line.
ssadetsky
parents:
diff
changeset
|
64 |
int width = area.getWidth(); |
9cc90ad7cf9a
6866751: J2SE_Swing_Reg: the caret disappears when moving to the end of the line.
ssadetsky
parents:
diff
changeset
|
65 |
double caretX = |
9cc90ad7cf9a
6866751: J2SE_Swing_Reg: the caret disappears when moving to the end of the line.
ssadetsky
parents:
diff
changeset
|
66 |
area.getCaret().getMagicCaretPosition().getX(); |
9cc90ad7cf9a
6866751: J2SE_Swing_Reg: the caret disappears when moving to the end of the line.
ssadetsky
parents:
diff
changeset
|
67 |
if (width < caretX + 10) { |
9cc90ad7cf9a
6866751: J2SE_Swing_Reg: the caret disappears when moving to the end of the line.
ssadetsky
parents:
diff
changeset
|
68 |
throw new RuntimeException( |
9cc90ad7cf9a
6866751: J2SE_Swing_Reg: the caret disappears when moving to the end of the line.
ssadetsky
parents:
diff
changeset
|
69 |
"Width of the area (" + width + |
9cc90ad7cf9a
6866751: J2SE_Swing_Reg: the caret disappears when moving to the end of the line.
ssadetsky
parents:
diff
changeset
|
70 |
") is less than caret x-position " + |
9cc90ad7cf9a
6866751: J2SE_Swing_Reg: the caret disappears when moving to the end of the line.
ssadetsky
parents:
diff
changeset
|
71 |
caretX + 10); |
9cc90ad7cf9a
6866751: J2SE_Swing_Reg: the caret disappears when moving to the end of the line.
ssadetsky
parents:
diff
changeset
|
72 |
} |
9cc90ad7cf9a
6866751: J2SE_Swing_Reg: the caret disappears when moving to the end of the line.
ssadetsky
parents:
diff
changeset
|
73 |
} |
9cc90ad7cf9a
6866751: J2SE_Swing_Reg: the caret disappears when moving to the end of the line.
ssadetsky
parents:
diff
changeset
|
74 |
}); |
9cc90ad7cf9a
6866751: J2SE_Swing_Reg: the caret disappears when moving to the end of the line.
ssadetsky
parents:
diff
changeset
|
75 |
System.out.println("ok"); |
9cc90ad7cf9a
6866751: J2SE_Swing_Reg: the caret disappears when moving to the end of the line.
ssadetsky
parents:
diff
changeset
|
76 |
} finally { |
9cc90ad7cf9a
6866751: J2SE_Swing_Reg: the caret disappears when moving to the end of the line.
ssadetsky
parents:
diff
changeset
|
77 |
SwingUtilities.invokeAndWait(new Runnable() { |
9cc90ad7cf9a
6866751: J2SE_Swing_Reg: the caret disappears when moving to the end of the line.
ssadetsky
parents:
diff
changeset
|
78 |
@Override |
9cc90ad7cf9a
6866751: J2SE_Swing_Reg: the caret disappears when moving to the end of the line.
ssadetsky
parents:
diff
changeset
|
79 |
public void run() { |
9cc90ad7cf9a
6866751: J2SE_Swing_Reg: the caret disappears when moving to the end of the line.
ssadetsky
parents:
diff
changeset
|
80 |
frame.dispose(); |
9cc90ad7cf9a
6866751: J2SE_Swing_Reg: the caret disappears when moving to the end of the line.
ssadetsky
parents:
diff
changeset
|
81 |
} |
9cc90ad7cf9a
6866751: J2SE_Swing_Reg: the caret disappears when moving to the end of the line.
ssadetsky
parents:
diff
changeset
|
82 |
}); |
9cc90ad7cf9a
6866751: J2SE_Swing_Reg: the caret disappears when moving to the end of the line.
ssadetsky
parents:
diff
changeset
|
83 |
} |
9cc90ad7cf9a
6866751: J2SE_Swing_Reg: the caret disappears when moving to the end of the line.
ssadetsky
parents:
diff
changeset
|
84 |
} |
9cc90ad7cf9a
6866751: J2SE_Swing_Reg: the caret disappears when moving to the end of the line.
ssadetsky
parents:
diff
changeset
|
85 |
|
9cc90ad7cf9a
6866751: J2SE_Swing_Reg: the caret disappears when moving to the end of the line.
ssadetsky
parents:
diff
changeset
|
86 |
static void setup(JFrame frame) { |
9cc90ad7cf9a
6866751: J2SE_Swing_Reg: the caret disappears when moving to the end of the line.
ssadetsky
parents:
diff
changeset
|
87 |
area = new JTextArea(); |
9cc90ad7cf9a
6866751: J2SE_Swing_Reg: the caret disappears when moving to the end of the line.
ssadetsky
parents:
diff
changeset
|
88 |
frame.getContentPane().add(new JScrollPane(area)); |
9cc90ad7cf9a
6866751: J2SE_Swing_Reg: the caret disappears when moving to the end of the line.
ssadetsky
parents:
diff
changeset
|
89 |
area.setText( |
9cc90ad7cf9a
6866751: J2SE_Swing_Reg: the caret disappears when moving to the end of the line.
ssadetsky
parents:
diff
changeset
|
90 |
"mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm"); |
9cc90ad7cf9a
6866751: J2SE_Swing_Reg: the caret disappears when moving to the end of the line.
ssadetsky
parents:
diff
changeset
|
91 |
area.getCaret().setDot(area.getText().length() + 1); |
9cc90ad7cf9a
6866751: J2SE_Swing_Reg: the caret disappears when moving to the end of the line.
ssadetsky
parents:
diff
changeset
|
92 |
|
9cc90ad7cf9a
6866751: J2SE_Swing_Reg: the caret disappears when moving to the end of the line.
ssadetsky
parents:
diff
changeset
|
93 |
frame.setSize(300, 200); |
9cc90ad7cf9a
6866751: J2SE_Swing_Reg: the caret disappears when moving to the end of the line.
ssadetsky
parents:
diff
changeset
|
94 |
frame.setVisible(true); |
9cc90ad7cf9a
6866751: J2SE_Swing_Reg: the caret disappears when moving to the end of the line.
ssadetsky
parents:
diff
changeset
|
95 |
|
9cc90ad7cf9a
6866751: J2SE_Swing_Reg: the caret disappears when moving to the end of the line.
ssadetsky
parents:
diff
changeset
|
96 |
area.requestFocus(); |
9cc90ad7cf9a
6866751: J2SE_Swing_Reg: the caret disappears when moving to the end of the line.
ssadetsky
parents:
diff
changeset
|
97 |
|
9cc90ad7cf9a
6866751: J2SE_Swing_Reg: the caret disappears when moving to the end of the line.
ssadetsky
parents:
diff
changeset
|
98 |
} |
9cc90ad7cf9a
6866751: J2SE_Swing_Reg: the caret disappears when moving to the end of the line.
ssadetsky
parents:
diff
changeset
|
99 |
|
9cc90ad7cf9a
6866751: J2SE_Swing_Reg: the caret disappears when moving to the end of the line.
ssadetsky
parents:
diff
changeset
|
100 |
} |