3563N/A/*
3563N/A * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
3563N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3563N/A *
3563N/A * This code is free software; you can redistribute it and/or modify it
3563N/A * under the terms of the GNU General Public License version 2 only, as
3563N/A * published by the Free Software Foundation.
3563N/A *
3563N/A * This code is distributed in the hope that it will be useful, but WITHOUT
3563N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3563N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
3563N/A * version 2 for more details (a copy is included in the LICENSE file that
3563N/A * accompanied this code).
3563N/A *
3563N/A * You should have received a copy of the GNU General Public License version
3563N/A * 2 along with this work; if not, write to the Free Software Foundation,
3563N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
3563N/A *
3563N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
3563N/A * or visit www.oracle.com if you need additional information or have any
3563N/A * questions.
3563N/A */
3563N/A
3563N/A/* @test
3563N/A * @bug 6474153
3563N/A * @summary LookAndFeel.makeKeyBindings(...) doesn't ignore last element in keyBindingList with odd size
3563N/A * @author Alexander Potochkin
3563N/A */
3563N/A
3563N/Aimport javax.swing.KeyStroke;
3563N/Aimport javax.swing.LookAndFeel;
3563N/Aimport javax.swing.text.DefaultEditorKit;
3563N/Aimport javax.swing.text.JTextComponent;
3563N/A
3563N/Apublic class bug6474153 {
3563N/A
3563N/A public static void main(String... args) throws Exception {
3563N/A checkArray(LookAndFeel.makeKeyBindings(new Object[] {"UP", DefaultEditorKit.upAction} ));
3563N/A checkArray(LookAndFeel.makeKeyBindings(new Object[] {"UP", DefaultEditorKit.upAction, "PAGE_UP"} ));
3563N/A }
3563N/A
3563N/A private static void checkArray(JTextComponent.KeyBinding[] keyActionArray) {
3563N/A if (keyActionArray.length != 1) {
3563N/A throw new RuntimeException("Wrong array lenght!");
3563N/A }
3563N/A if (!DefaultEditorKit.upAction.equals(keyActionArray[0].actionName)) {
3563N/A throw new RuntimeException("Wrong action name!");
3563N/A }
3563N/A if (!KeyStroke.getKeyStroke("UP").equals(keyActionArray[0].key)) {
3563N/A throw new RuntimeException("Wrong keystroke!");
3563N/A }
3563N/A }
3563N/A}