5052N/A/*
5052N/A * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
5052N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5052N/A *
5052N/A * This code is free software; you can redistribute it and/or modify it
5052N/A * under the terms of the GNU General Public License version 2 only, as
5052N/A * published by the Free Software Foundation.
5052N/A *
5052N/A * This code is distributed in the hope that it will be useful, but WITHOUT
5052N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
5052N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
5052N/A * version 2 for more details (a copy is included in the LICENSE file that
5052N/A * accompanied this code).
5052N/A *
5052N/A * You should have received a copy of the GNU General Public License version
5052N/A * 2 along with this work; if not, write to the Free Software Foundation,
5052N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
5052N/A *
5052N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
5052N/A * or visit www.oracle.com if you need additional information or have any
5052N/A * questions.
5052N/A */
5052N/A
5052N/A/* @test 1.0 04/04/23
5052N/A @bug 5012888
5052N/A @summary REGRESSION: Click & hold on arrow of JSpinner only transfers focus
5052N/A @author Konstantin Eremin
5052N/A @run main bug5012888
5052N/A*/
5052N/Aimport javax.swing.*;
5052N/Aimport javax.swing.event.*;
5052N/Aimport java.awt.*;
5052N/Aimport java.awt.event.*;
5052N/A
5052N/Apublic class bug5012888 extends JFrame {
5052N/A JSpinner spinner1, spinner2;
5052N/A public bug5012888() {
5052N/A spinner1 = new JSpinner(new SpinnerNumberModel(0, -1000, 1000, 1));
5052N/A spinner2 = new JSpinner(new SpinnerNumberModel(1, -1000, 1000, 1));
5052N/A Container pane = getContentPane();
5052N/A pane.setLayout(new BorderLayout());
5052N/A pane.add(spinner1, BorderLayout.NORTH);
5052N/A pane.add(spinner2, BorderLayout.SOUTH);
5052N/A }
5052N/A public void doTest() throws Exception {
5052N/A ((sun.awt.SunToolkit)Toolkit.getDefaultToolkit()).realSync();
5052N/A Point p = spinner2.getLocationOnScreen();
5052N/A Rectangle rect = spinner2.getBounds();
5052N/A Robot robot = new Robot();
5052N/A robot.mouseMove(p.x+rect.width-5, p.y+5);
5052N/A robot.mousePress(InputEvent.BUTTON1_MASK);
5052N/A Thread.sleep(1000);
5052N/A robot.mouseRelease(InputEvent.BUTTON1_MASK);
5052N/A if ( ((Integer) spinner2.getValue()).intValue() == 1 ) {
5052N/A throw new Error("Spinner value should be more than 1");
5052N/A }
5052N/A }
5052N/A public static void main(String[] argv) throws Exception {
5052N/A bug5012888 b = new bug5012888();
5052N/A b.setBounds(0, 0, 100, 100);
5052N/A b.setVisible(true);
5052N/A b.doTest();
5052N/A }
5052N/A}