Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/javax/swing/JSpinner/5012888/bug5012888.java
38918 views
/*1* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/* @test 1.0 04/04/2324@bug 501288825@summary REGRESSION: Click & hold on arrow of JSpinner only transfers focus26@author Konstantin Eremin27@run main bug501288828*/29import javax.swing.*;30import javax.swing.event.*;31import java.awt.*;32import java.awt.event.*;3334public class bug5012888 extends JFrame {35JSpinner spinner1, spinner2;36public bug5012888() {37spinner1 = new JSpinner(new SpinnerNumberModel(0, -1000, 1000, 1));38spinner2 = new JSpinner(new SpinnerNumberModel(1, -1000, 1000, 1));39Container pane = getContentPane();40pane.setLayout(new BorderLayout());41pane.add(spinner1, BorderLayout.NORTH);42pane.add(spinner2, BorderLayout.SOUTH);43}44public void doTest() throws Exception {45Robot robot = new Robot();46robot.waitForIdle();47Point p = spinner2.getLocationOnScreen();48Rectangle rect = spinner2.getBounds();49robot.mouseMove(p.x+rect.width-5, p.y+5);50robot.mousePress(InputEvent.BUTTON1_MASK);51Thread.sleep(1000);52robot.mouseRelease(InputEvent.BUTTON1_MASK);53if ( ((Integer) spinner2.getValue()).intValue() == 1 ) {54throw new Error("Spinner value should be more than 1");55}56}57public static void main(String[] argv) throws Exception {58bug5012888 b = new bug5012888();59b.setBounds(0, 0, 100, 100);60b.setVisible(true);61b.doTest();62}63}646566