Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/javax/swing/JSlider/6524424/bug6524424.java
38855 views
/*1* Copyright (c) 2008, 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/* @test24* @bug 652442425* @summary JSlider Clicking In Tracks Behavior Inconsistent For Different Tick Spacings26* @author Pavel Porvatov27* @run applet/manual=done bug6524424.html28*/2930import java.awt.*;31import javax.swing.*;3233import com.sun.java.swing.plaf.windows.WindowsLookAndFeel;3435public class bug6524424 extends JApplet {36public static void main(String[] args) {37try {38UIManager.setLookAndFeel(new WindowsLookAndFeel());39} catch (UnsupportedLookAndFeelException e) {40e.printStackTrace();4142return;43}4445TestPanel panel = new TestPanel();4647JFrame frame = new JFrame();4849frame.setContentPane(panel);50frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);51frame.pack();52frame.setLocationRelativeTo(null);5354frame.setVisible(true);55}5657public void init() {58TestPanel panel = new TestPanel();5960setContentPane(panel);61}6263private static class TestPanel extends JPanel {6465private TestPanel() {66super(new GridBagLayout());6768JSlider slider1 = createSlider(1, 2);69JSlider slider2 = createSlider(2, 4);70JSlider slider3 = createSlider(3, 6);7172addComponent(this, slider1);73addComponent(this, slider2);74addComponent(this, slider3);75}7677private JSlider createSlider(int tickMinor, int tickMajor) {78JSlider result = new JSlider();7980result.setPaintLabels(true);81result.setPaintTicks(true);82result.setSnapToTicks(true);83result.setMinimum(0);84result.setMaximum(12);85result.setMinorTickSpacing(tickMinor);86result.setMajorTickSpacing(tickMajor);8788return result;89}90}9192private static void addComponent(JPanel panel, Component component) {93panel.add(component, new GridBagConstraints(0,94panel.getComponentCount(), 1, 1,951, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL,96new Insets(0, 0, 0, 0), 0, 0));97}98}99100101