author | ssadetsky |
Tue, 14 Jul 2015 13:57:16 +0300 | |
changeset 31886 | 5787a1b5682a |
child 39011 | 6649a38574b0 |
permissions | -rw-r--r-- |
31886
5787a1b5682a
8076164: [JTextField] When input too long Thai character, cursor's behavior is odd
ssadetsky
parents:
diff
changeset
|
1 |
/* |
5787a1b5682a
8076164: [JTextField] When input too long Thai character, cursor's behavior is odd
ssadetsky
parents:
diff
changeset
|
2 |
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. |
5787a1b5682a
8076164: [JTextField] When input too long Thai character, cursor's behavior is odd
ssadetsky
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
5787a1b5682a
8076164: [JTextField] When input too long Thai character, cursor's behavior is odd
ssadetsky
parents:
diff
changeset
|
4 |
* |
5787a1b5682a
8076164: [JTextField] When input too long Thai character, cursor's behavior is odd
ssadetsky
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
5787a1b5682a
8076164: [JTextField] When input too long Thai character, cursor's behavior is odd
ssadetsky
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
5787a1b5682a
8076164: [JTextField] When input too long Thai character, cursor's behavior is odd
ssadetsky
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
5787a1b5682a
8076164: [JTextField] When input too long Thai character, cursor's behavior is odd
ssadetsky
parents:
diff
changeset
|
8 |
* |
5787a1b5682a
8076164: [JTextField] When input too long Thai character, cursor's behavior is odd
ssadetsky
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
5787a1b5682a
8076164: [JTextField] When input too long Thai character, cursor's behavior is odd
ssadetsky
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
5787a1b5682a
8076164: [JTextField] When input too long Thai character, cursor's behavior is odd
ssadetsky
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
5787a1b5682a
8076164: [JTextField] When input too long Thai character, cursor's behavior is odd
ssadetsky
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
5787a1b5682a
8076164: [JTextField] When input too long Thai character, cursor's behavior is odd
ssadetsky
parents:
diff
changeset
|
13 |
* accompanied this code). |
5787a1b5682a
8076164: [JTextField] When input too long Thai character, cursor's behavior is odd
ssadetsky
parents:
diff
changeset
|
14 |
* |
5787a1b5682a
8076164: [JTextField] When input too long Thai character, cursor's behavior is odd
ssadetsky
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
5787a1b5682a
8076164: [JTextField] When input too long Thai character, cursor's behavior is odd
ssadetsky
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
5787a1b5682a
8076164: [JTextField] When input too long Thai character, cursor's behavior is odd
ssadetsky
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
5787a1b5682a
8076164: [JTextField] When input too long Thai character, cursor's behavior is odd
ssadetsky
parents:
diff
changeset
|
18 |
* |
5787a1b5682a
8076164: [JTextField] When input too long Thai character, cursor's behavior is odd
ssadetsky
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
5787a1b5682a
8076164: [JTextField] When input too long Thai character, cursor's behavior is odd
ssadetsky
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
5787a1b5682a
8076164: [JTextField] When input too long Thai character, cursor's behavior is odd
ssadetsky
parents:
diff
changeset
|
21 |
* questions. |
5787a1b5682a
8076164: [JTextField] When input too long Thai character, cursor's behavior is odd
ssadetsky
parents:
diff
changeset
|
22 |
*/ |
5787a1b5682a
8076164: [JTextField] When input too long Thai character, cursor's behavior is odd
ssadetsky
parents:
diff
changeset
|
23 |
|
5787a1b5682a
8076164: [JTextField] When input too long Thai character, cursor's behavior is odd
ssadetsky
parents:
diff
changeset
|
24 |
/* @test |
5787a1b5682a
8076164: [JTextField] When input too long Thai character, cursor's behavior is odd
ssadetsky
parents:
diff
changeset
|
25 |
@bug 8076164 |
5787a1b5682a
8076164: [JTextField] When input too long Thai character, cursor's behavior is odd
ssadetsky
parents:
diff
changeset
|
26 |
@summary [JTextField] When input too long Thai character, cursor's behavior |
5787a1b5682a
8076164: [JTextField] When input too long Thai character, cursor's behavior is odd
ssadetsky
parents:
diff
changeset
|
27 |
is odd |
5787a1b5682a
8076164: [JTextField] When input too long Thai character, cursor's behavior is odd
ssadetsky
parents:
diff
changeset
|
28 |
@author Semyon Sadetsky |
5787a1b5682a
8076164: [JTextField] When input too long Thai character, cursor's behavior is odd
ssadetsky
parents:
diff
changeset
|
29 |
*/ |
5787a1b5682a
8076164: [JTextField] When input too long Thai character, cursor's behavior is odd
ssadetsky
parents:
diff
changeset
|
30 |
|
5787a1b5682a
8076164: [JTextField] When input too long Thai character, cursor's behavior is odd
ssadetsky
parents:
diff
changeset
|
31 |
import javax.swing.*; |
5787a1b5682a
8076164: [JTextField] When input too long Thai character, cursor's behavior is odd
ssadetsky
parents:
diff
changeset
|
32 |
import javax.swing.SwingUtilities; |
5787a1b5682a
8076164: [JTextField] When input too long Thai character, cursor's behavior is odd
ssadetsky
parents:
diff
changeset
|
33 |
import javax.swing.text.BadLocationException; |
5787a1b5682a
8076164: [JTextField] When input too long Thai character, cursor's behavior is odd
ssadetsky
parents:
diff
changeset
|
34 |
import java.lang.Override; |
5787a1b5682a
8076164: [JTextField] When input too long Thai character, cursor's behavior is odd
ssadetsky
parents:
diff
changeset
|
35 |
import java.lang.Runnable; |
5787a1b5682a
8076164: [JTextField] When input too long Thai character, cursor's behavior is odd
ssadetsky
parents:
diff
changeset
|
36 |
|
5787a1b5682a
8076164: [JTextField] When input too long Thai character, cursor's behavior is odd
ssadetsky
parents:
diff
changeset
|
37 |
public class I18NViewNoWrapMinSpan { |
5787a1b5682a
8076164: [JTextField] When input too long Thai character, cursor's behavior is odd
ssadetsky
parents:
diff
changeset
|
38 |
|
5787a1b5682a
8076164: [JTextField] When input too long Thai character, cursor's behavior is odd
ssadetsky
parents:
diff
changeset
|
39 |
public static void main(String[] args) throws Exception { |
5787a1b5682a
8076164: [JTextField] When input too long Thai character, cursor's behavior is odd
ssadetsky
parents:
diff
changeset
|
40 |
SwingUtilities.invokeAndWait(new Runnable() { |
5787a1b5682a
8076164: [JTextField] When input too long Thai character, cursor's behavior is odd
ssadetsky
parents:
diff
changeset
|
41 |
@Override |
5787a1b5682a
8076164: [JTextField] When input too long Thai character, cursor's behavior is odd
ssadetsky
parents:
diff
changeset
|
42 |
public void run() { |
5787a1b5682a
8076164: [JTextField] When input too long Thai character, cursor's behavior is odd
ssadetsky
parents:
diff
changeset
|
43 |
try { |
5787a1b5682a
8076164: [JTextField] When input too long Thai character, cursor's behavior is odd
ssadetsky
parents:
diff
changeset
|
44 |
JTextField textField = new JTextField(15); |
5787a1b5682a
8076164: [JTextField] When input too long Thai character, cursor's behavior is odd
ssadetsky
parents:
diff
changeset
|
45 |
textField.setText("ม12345"); |
5787a1b5682a
8076164: [JTextField] When input too long Thai character, cursor's behavior is odd
ssadetsky
parents:
diff
changeset
|
46 |
float noSpaceMin = textField.getUI().getRootView(textField) |
5787a1b5682a
8076164: [JTextField] When input too long Thai character, cursor's behavior is odd
ssadetsky
parents:
diff
changeset
|
47 |
.getMinimumSpan(0); |
5787a1b5682a
8076164: [JTextField] When input too long Thai character, cursor's behavior is odd
ssadetsky
parents:
diff
changeset
|
48 |
textField.getDocument().insertString(3, " ", null); |
5787a1b5682a
8076164: [JTextField] When input too long Thai character, cursor's behavior is odd
ssadetsky
parents:
diff
changeset
|
49 |
if (noSpaceMin > textField.getUI().getRootView(textField) |
5787a1b5682a
8076164: [JTextField] When input too long Thai character, cursor's behavior is odd
ssadetsky
parents:
diff
changeset
|
50 |
.getMinimumSpan(0)) { |
5787a1b5682a
8076164: [JTextField] When input too long Thai character, cursor's behavior is odd
ssadetsky
parents:
diff
changeset
|
51 |
throw new RuntimeException( |
5787a1b5682a
8076164: [JTextField] When input too long Thai character, cursor's behavior is odd
ssadetsky
parents:
diff
changeset
|
52 |
"Minimum span is calculated for wrapped text"); |
5787a1b5682a
8076164: [JTextField] When input too long Thai character, cursor's behavior is odd
ssadetsky
parents:
diff
changeset
|
53 |
} |
5787a1b5682a
8076164: [JTextField] When input too long Thai character, cursor's behavior is odd
ssadetsky
parents:
diff
changeset
|
54 |
} catch (BadLocationException e) { |
5787a1b5682a
8076164: [JTextField] When input too long Thai character, cursor's behavior is odd
ssadetsky
parents:
diff
changeset
|
55 |
throw new RuntimeException(e); |
5787a1b5682a
8076164: [JTextField] When input too long Thai character, cursor's behavior is odd
ssadetsky
parents:
diff
changeset
|
56 |
} |
5787a1b5682a
8076164: [JTextField] When input too long Thai character, cursor's behavior is odd
ssadetsky
parents:
diff
changeset
|
57 |
} |
5787a1b5682a
8076164: [JTextField] When input too long Thai character, cursor's behavior is odd
ssadetsky
parents:
diff
changeset
|
58 |
}); |
5787a1b5682a
8076164: [JTextField] When input too long Thai character, cursor's behavior is odd
ssadetsky
parents:
diff
changeset
|
59 |
System.out.println("ok"); |
5787a1b5682a
8076164: [JTextField] When input too long Thai character, cursor's behavior is odd
ssadetsky
parents:
diff
changeset
|
60 |
} |
5787a1b5682a
8076164: [JTextField] When input too long Thai character, cursor's behavior is odd
ssadetsky
parents:
diff
changeset
|
61 |
} |