Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/javax/swing/JSplitPane/4885629/bug4885629.java
38854 views
/*1* Copyright (c) 2011, 2012, 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* @bug 488562926* @summary With JSplitPane in VERTICAL_SPLIT, SplitPaneBorder draws bottom edge of divider27* @author Andrey Pikalev28*/2930import javax.swing.*;31import javax.swing.border.Border;32import javax.swing.border.EmptyBorder;33import javax.swing.plaf.basic.BasicBorders;34import javax.swing.plaf.basic.BasicLookAndFeel;35import javax.swing.plaf.basic.BasicSplitPaneUI;36import java.awt.*;373839public class bug4885629 {4041private static final Color darkShadow = new Color(100,120,200);42private static final Color darkHighlight = new Color(200,120,50);43private static final Color lightHighlight = darkHighlight.brighter();44private static final Color BGCOLOR = Color.blue;4546private static JSplitPane sp;4748public static void main(String[] args) throws Exception {49UIManager.setLookAndFeel(new BasicLookAndFeel() {50public boolean isSupportedLookAndFeel(){ return true; }51public boolean isNativeLookAndFeel(){ return false; }52public String getDescription() { return "Foo"; }53public String getID() { return "FooID"; }54public String getName() { return "FooName"; }55});5657SwingUtilities.invokeAndWait(new Runnable() {58public void run() {59JFrame frame = new JFrame();6061JComponent a = new JPanel();62a.setBackground(Color.white);63a.setMinimumSize(new Dimension(10, 10));6465JComponent b = new JPanel();66b.setBackground(Color.white);67b.setMinimumSize(new Dimension(10, 10));6869sp = new JSplitPane(JSplitPane.VERTICAL_SPLIT, a, b);70sp.setPreferredSize(new Dimension(20, 20));71sp.setBackground(BGCOLOR);7273Border bo = new BasicBorders.SplitPaneBorder(lightHighlight,74Color.red);75Border ibo = new EmptyBorder(0, 0, 0, 0);76sp.setBorder(bo);77sp.setMinimumSize(new Dimension(200, 200));7879((BasicSplitPaneUI) sp.getUI()).getDivider().setBorder(ibo);8081frame.getContentPane().setLayout(new FlowLayout());82frame.getContentPane().setBackground(darkShadow);83frame.getContentPane().add(sp);8485frame.setSize(200, 200);86frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);87frame.setVisible(true);88}89});9091final Robot robot = new Robot();92robot.waitForIdle();93robot.delay(1000);9495SwingUtilities.invokeAndWait(new Runnable() {96public void run() {97Rectangle rect = ((BasicSplitPaneUI) sp.getUI()).getDivider().getBounds();9899Point p = rect.getLocation();100101SwingUtilities.convertPointToScreen(p, sp);102103for (int i = 0; i < rect.width; i++) {104if (!BGCOLOR.equals(robot.getPixelColor(p.x + i, p.y + rect.height - 1))) {105throw new Error("The divider's area has incorrect color.");106}107}108}109});110}111}112113114