Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/javax/swing/JSlider/6401380/bug6401380.java
38855 views
/*1* Copyright (c) 2011, 2014, 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*/22/* @test23@bug 640138024@summary JSlider - mouse click ont the left side of the knob is ignored.25@library ../../../../lib/testlibrary26@build ExtendedRobot27@author Alexander Potochkin28@run main bug640138029*/3031import javax.swing.*;32import javax.swing.plaf.basic.BasicSliderUI;33import java.awt.*;34import java.awt.event.InputEvent;3536public class bug6401380 extends JFrame {37private static JSlider slider;3839public bug6401380() {40setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);4142slider = new JSlider();43slider.setMajorTickSpacing(0);44slider.setMaximum(50);45slider.setMinorTickSpacing(10);46slider.setPaintLabels(true);47slider.setPaintTicks(true);48slider.setSnapToTicks(true);4950// MetalSliderUI overrides scrollDueToClickInTrack() method51// so this test doens't work for Metal52slider.setUI(new BasicSliderUI(slider));5354add(slider);55setSize(200, 200);56}5758public static void main(String[] args) throws Exception {5960ExtendedRobot robot = new ExtendedRobot();61robot.setAutoDelay(10);6263SwingUtilities.invokeAndWait(new Runnable() {64public void run() {65new bug6401380().setVisible(true);66}67});68robot.waitForIdle();6970Point l = slider.getLocationOnScreen();71robot.glide(0, 0, l.x + slider.getWidth() / 2, l.y + slider.getHeight() / 2);72robot.mousePress(InputEvent.BUTTON1_MASK);73robot.mouseRelease(InputEvent.BUTTON1_MASK);7475robot.waitForIdle();7677if (slider.getValue() == slider.getMaximum()) {78throw new RuntimeException("Slider value unchanged");79}80}81}828384