Path: blob/master/test/jdk/javax/swing/JSlider/6401380/bug6401380.java
41153 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*/2223/*24* @test25* @key headful26* @bug 640138027* @summary JSlider - mouse click ont the left side of the knob is ignored.28* @library /lib/client29* @build ExtendedRobot30* @author Alexander Potochkin31* @run main bug640138032*/3334import javax.swing.*;35import javax.swing.plaf.basic.BasicSliderUI;36import java.awt.*;37import java.awt.event.InputEvent;3839public class bug6401380 extends JFrame {40private static JSlider slider;4142public bug6401380() {43setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);4445slider = new JSlider();46slider.setMajorTickSpacing(0);47slider.setMaximum(50);48slider.setMinorTickSpacing(10);49slider.setPaintLabels(true);50slider.setPaintTicks(true);51slider.setSnapToTicks(true);5253// MetalSliderUI overrides scrollDueToClickInTrack() method54// so this test doens't work for Metal55slider.setUI(new BasicSliderUI(slider));5657add(slider);58setSize(200, 200);59}6061public static void main(String[] args) throws Exception {6263ExtendedRobot robot = new ExtendedRobot();64robot.setAutoDelay(10);6566SwingUtilities.invokeAndWait(new Runnable() {67public void run() {68new bug6401380().setVisible(true);69}70});71robot.waitForIdle();7273Point l = slider.getLocationOnScreen();74robot.glide(0, 0, l.x + slider.getWidth() / 2, l.y + slider.getHeight() / 2);75robot.mousePress(InputEvent.BUTTON1_MASK);76robot.mouseRelease(InputEvent.BUTTON1_MASK);7778robot.waitForIdle();7980if (slider.getValue() == slider.getMaximum()) {81throw new RuntimeException("Slider value unchanged");82}83}84}858687