author | mfang |
Wed, 17 Aug 2011 14:18:26 -0700 | |
changeset 10294 | 8fcdae2a7ec7 |
parent 8380 | 9b9f901a909d |
permissions | -rw-r--r-- |
8380
9b9f901a909d
6474153: LookAndFeel.makeKeyBindings(...) doesn't ignore last element in keyBindingList with odd size
alexp
parents:
diff
changeset
|
1 |
/* |
9b9f901a909d
6474153: LookAndFeel.makeKeyBindings(...) doesn't ignore last element in keyBindingList with odd size
alexp
parents:
diff
changeset
|
2 |
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. |
9b9f901a909d
6474153: LookAndFeel.makeKeyBindings(...) doesn't ignore last element in keyBindingList with odd size
alexp
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
9b9f901a909d
6474153: LookAndFeel.makeKeyBindings(...) doesn't ignore last element in keyBindingList with odd size
alexp
parents:
diff
changeset
|
4 |
* |
9b9f901a909d
6474153: LookAndFeel.makeKeyBindings(...) doesn't ignore last element in keyBindingList with odd size
alexp
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
9b9f901a909d
6474153: LookAndFeel.makeKeyBindings(...) doesn't ignore last element in keyBindingList with odd size
alexp
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
9b9f901a909d
6474153: LookAndFeel.makeKeyBindings(...) doesn't ignore last element in keyBindingList with odd size
alexp
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
9b9f901a909d
6474153: LookAndFeel.makeKeyBindings(...) doesn't ignore last element in keyBindingList with odd size
alexp
parents:
diff
changeset
|
8 |
* |
9b9f901a909d
6474153: LookAndFeel.makeKeyBindings(...) doesn't ignore last element in keyBindingList with odd size
alexp
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
9b9f901a909d
6474153: LookAndFeel.makeKeyBindings(...) doesn't ignore last element in keyBindingList with odd size
alexp
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
9b9f901a909d
6474153: LookAndFeel.makeKeyBindings(...) doesn't ignore last element in keyBindingList with odd size
alexp
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
9b9f901a909d
6474153: LookAndFeel.makeKeyBindings(...) doesn't ignore last element in keyBindingList with odd size
alexp
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
9b9f901a909d
6474153: LookAndFeel.makeKeyBindings(...) doesn't ignore last element in keyBindingList with odd size
alexp
parents:
diff
changeset
|
13 |
* accompanied this code). |
9b9f901a909d
6474153: LookAndFeel.makeKeyBindings(...) doesn't ignore last element in keyBindingList with odd size
alexp
parents:
diff
changeset
|
14 |
* |
9b9f901a909d
6474153: LookAndFeel.makeKeyBindings(...) doesn't ignore last element in keyBindingList with odd size
alexp
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
9b9f901a909d
6474153: LookAndFeel.makeKeyBindings(...) doesn't ignore last element in keyBindingList with odd size
alexp
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
9b9f901a909d
6474153: LookAndFeel.makeKeyBindings(...) doesn't ignore last element in keyBindingList with odd size
alexp
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
9b9f901a909d
6474153: LookAndFeel.makeKeyBindings(...) doesn't ignore last element in keyBindingList with odd size
alexp
parents:
diff
changeset
|
18 |
* |
9b9f901a909d
6474153: LookAndFeel.makeKeyBindings(...) doesn't ignore last element in keyBindingList with odd size
alexp
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
9b9f901a909d
6474153: LookAndFeel.makeKeyBindings(...) doesn't ignore last element in keyBindingList with odd size
alexp
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
9b9f901a909d
6474153: LookAndFeel.makeKeyBindings(...) doesn't ignore last element in keyBindingList with odd size
alexp
parents:
diff
changeset
|
21 |
* questions. |
9b9f901a909d
6474153: LookAndFeel.makeKeyBindings(...) doesn't ignore last element in keyBindingList with odd size
alexp
parents:
diff
changeset
|
22 |
*/ |
9b9f901a909d
6474153: LookAndFeel.makeKeyBindings(...) doesn't ignore last element in keyBindingList with odd size
alexp
parents:
diff
changeset
|
23 |
|
9b9f901a909d
6474153: LookAndFeel.makeKeyBindings(...) doesn't ignore last element in keyBindingList with odd size
alexp
parents:
diff
changeset
|
24 |
/* @test |
9b9f901a909d
6474153: LookAndFeel.makeKeyBindings(...) doesn't ignore last element in keyBindingList with odd size
alexp
parents:
diff
changeset
|
25 |
* @bug 6474153 |
9b9f901a909d
6474153: LookAndFeel.makeKeyBindings(...) doesn't ignore last element in keyBindingList with odd size
alexp
parents:
diff
changeset
|
26 |
* @summary LookAndFeel.makeKeyBindings(...) doesn't ignore last element in keyBindingList with odd size |
9b9f901a909d
6474153: LookAndFeel.makeKeyBindings(...) doesn't ignore last element in keyBindingList with odd size
alexp
parents:
diff
changeset
|
27 |
* @author Alexander Potochkin |
9b9f901a909d
6474153: LookAndFeel.makeKeyBindings(...) doesn't ignore last element in keyBindingList with odd size
alexp
parents:
diff
changeset
|
28 |
*/ |
9b9f901a909d
6474153: LookAndFeel.makeKeyBindings(...) doesn't ignore last element in keyBindingList with odd size
alexp
parents:
diff
changeset
|
29 |
|
9b9f901a909d
6474153: LookAndFeel.makeKeyBindings(...) doesn't ignore last element in keyBindingList with odd size
alexp
parents:
diff
changeset
|
30 |
import javax.swing.KeyStroke; |
9b9f901a909d
6474153: LookAndFeel.makeKeyBindings(...) doesn't ignore last element in keyBindingList with odd size
alexp
parents:
diff
changeset
|
31 |
import javax.swing.LookAndFeel; |
9b9f901a909d
6474153: LookAndFeel.makeKeyBindings(...) doesn't ignore last element in keyBindingList with odd size
alexp
parents:
diff
changeset
|
32 |
import javax.swing.text.DefaultEditorKit; |
9b9f901a909d
6474153: LookAndFeel.makeKeyBindings(...) doesn't ignore last element in keyBindingList with odd size
alexp
parents:
diff
changeset
|
33 |
import javax.swing.text.JTextComponent; |
9b9f901a909d
6474153: LookAndFeel.makeKeyBindings(...) doesn't ignore last element in keyBindingList with odd size
alexp
parents:
diff
changeset
|
34 |
|
9b9f901a909d
6474153: LookAndFeel.makeKeyBindings(...) doesn't ignore last element in keyBindingList with odd size
alexp
parents:
diff
changeset
|
35 |
public class bug6474153 { |
9b9f901a909d
6474153: LookAndFeel.makeKeyBindings(...) doesn't ignore last element in keyBindingList with odd size
alexp
parents:
diff
changeset
|
36 |
|
9b9f901a909d
6474153: LookAndFeel.makeKeyBindings(...) doesn't ignore last element in keyBindingList with odd size
alexp
parents:
diff
changeset
|
37 |
public static void main(String... args) throws Exception { |
9b9f901a909d
6474153: LookAndFeel.makeKeyBindings(...) doesn't ignore last element in keyBindingList with odd size
alexp
parents:
diff
changeset
|
38 |
checkArray(LookAndFeel.makeKeyBindings(new Object[] {"UP", DefaultEditorKit.upAction} )); |
9b9f901a909d
6474153: LookAndFeel.makeKeyBindings(...) doesn't ignore last element in keyBindingList with odd size
alexp
parents:
diff
changeset
|
39 |
checkArray(LookAndFeel.makeKeyBindings(new Object[] {"UP", DefaultEditorKit.upAction, "PAGE_UP"} )); |
9b9f901a909d
6474153: LookAndFeel.makeKeyBindings(...) doesn't ignore last element in keyBindingList with odd size
alexp
parents:
diff
changeset
|
40 |
} |
9b9f901a909d
6474153: LookAndFeel.makeKeyBindings(...) doesn't ignore last element in keyBindingList with odd size
alexp
parents:
diff
changeset
|
41 |
|
9b9f901a909d
6474153: LookAndFeel.makeKeyBindings(...) doesn't ignore last element in keyBindingList with odd size
alexp
parents:
diff
changeset
|
42 |
private static void checkArray(JTextComponent.KeyBinding[] keyActionArray) { |
9b9f901a909d
6474153: LookAndFeel.makeKeyBindings(...) doesn't ignore last element in keyBindingList with odd size
alexp
parents:
diff
changeset
|
43 |
if (keyActionArray.length != 1) { |
9b9f901a909d
6474153: LookAndFeel.makeKeyBindings(...) doesn't ignore last element in keyBindingList with odd size
alexp
parents:
diff
changeset
|
44 |
throw new RuntimeException("Wrong array lenght!"); |
9b9f901a909d
6474153: LookAndFeel.makeKeyBindings(...) doesn't ignore last element in keyBindingList with odd size
alexp
parents:
diff
changeset
|
45 |
} |
9b9f901a909d
6474153: LookAndFeel.makeKeyBindings(...) doesn't ignore last element in keyBindingList with odd size
alexp
parents:
diff
changeset
|
46 |
if (!DefaultEditorKit.upAction.equals(keyActionArray[0].actionName)) { |
9b9f901a909d
6474153: LookAndFeel.makeKeyBindings(...) doesn't ignore last element in keyBindingList with odd size
alexp
parents:
diff
changeset
|
47 |
throw new RuntimeException("Wrong action name!"); |
9b9f901a909d
6474153: LookAndFeel.makeKeyBindings(...) doesn't ignore last element in keyBindingList with odd size
alexp
parents:
diff
changeset
|
48 |
} |
9b9f901a909d
6474153: LookAndFeel.makeKeyBindings(...) doesn't ignore last element in keyBindingList with odd size
alexp
parents:
diff
changeset
|
49 |
if (!KeyStroke.getKeyStroke("UP").equals(keyActionArray[0].key)) { |
9b9f901a909d
6474153: LookAndFeel.makeKeyBindings(...) doesn't ignore last element in keyBindingList with odd size
alexp
parents:
diff
changeset
|
50 |
throw new RuntimeException("Wrong keystroke!"); |
9b9f901a909d
6474153: LookAndFeel.makeKeyBindings(...) doesn't ignore last element in keyBindingList with odd size
alexp
parents:
diff
changeset
|
51 |
} |
9b9f901a909d
6474153: LookAndFeel.makeKeyBindings(...) doesn't ignore last element in keyBindingList with odd size
alexp
parents:
diff
changeset
|
52 |
} |
9b9f901a909d
6474153: LookAndFeel.makeKeyBindings(...) doesn't ignore last element in keyBindingList with odd size
alexp
parents:
diff
changeset
|
53 |
} |