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