Path: blob/master/test/jdk/javax/swing/JSlider/6742358/bug6742358.java
41153 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 674235825* @summary MetalSliderUI paint wrong vertical disabled filled JSlider for DefaultMetalTheme26* @author Pavel Porvatov27* @run applet/manual=done bug6742358.html28*/2930import javax.swing.*;31import javax.swing.plaf.metal.DefaultMetalTheme;32import javax.swing.plaf.metal.MetalLookAndFeel;3334public class bug6742358 extends JApplet {35public static void main(String[] args) {36MetalLookAndFeel.setCurrentTheme(new DefaultMetalTheme());3738JFrame frame = new JFrame();3940frame.setContentPane(new TestPanel());41frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);42frame.pack();43frame.setLocationRelativeTo(null);4445frame.setVisible(true);46}4748public void init() {49MetalLookAndFeel.setCurrentTheme(new DefaultMetalTheme());5051TestPanel panel = new TestPanel();5253setContentPane(panel);54}5556private static class TestPanel extends JPanel {5758private TestPanel() {59JPanel pnVertical = new JPanel();6061pnVertical.setLayout(new BoxLayout(pnVertical, BoxLayout.Y_AXIS));6263for (int i = 0; i < 8; i++) {64pnVertical.add(createSlider(false, (i & 4) == 0, (i & 2) == 0, (i & 1) == 0));65}6667JPanel pnHorizontal = new JPanel();6869pnHorizontal.setLayout(new BoxLayout(pnHorizontal, BoxLayout.X_AXIS));7071for (int i = 0; i < 8; i++) {72pnHorizontal.add(createSlider(true, (i & 4) == 0, (i & 2) == 0, (i & 1) == 0));73}7475add(pnHorizontal);76add(pnVertical);77}78}7980private static JSlider createSlider(boolean vertical, boolean enabled, boolean filled, boolean inverted) {81JSlider result = new JSlider(vertical ? SwingConstants.VERTICAL : SwingConstants.HORIZONTAL, 0, 10, 5);8283result.setEnabled(enabled);84result.putClientProperty("JSlider.isFilled", filled);85result.setInverted(inverted);86result.setToolTipText("<html>vertical = " + vertical + "<br>enabled = " + enabled + "<br>filled = " + filled +87"<br>inverted = " + inverted + "</html>");8889return result;90}91}929394