Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openjdk-multiarch-jdk8u
Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/javax/swing/JSplitPane/4885629/bug4885629.java
38854 views
1
/*
2
* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
5
* This code is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 2 only, as
7
* published by the Free Software Foundation.
8
*
9
* This code is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12
* version 2 for more details (a copy is included in the LICENSE file that
13
* accompanied this code).
14
*
15
* You should have received a copy of the GNU General Public License version
16
* 2 along with this work; if not, write to the Free Software Foundation,
17
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18
*
19
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20
* or visit www.oracle.com if you need additional information or have any
21
* questions.
22
*/
23
24
/*
25
* @test
26
* @bug 4885629
27
* @summary With JSplitPane in VERTICAL_SPLIT, SplitPaneBorder draws bottom edge of divider
28
* @author Andrey Pikalev
29
*/
30
31
import javax.swing.*;
32
import javax.swing.border.Border;
33
import javax.swing.border.EmptyBorder;
34
import javax.swing.plaf.basic.BasicBorders;
35
import javax.swing.plaf.basic.BasicLookAndFeel;
36
import javax.swing.plaf.basic.BasicSplitPaneUI;
37
import java.awt.*;
38
39
40
public class bug4885629 {
41
42
private static final Color darkShadow = new Color(100,120,200);
43
private static final Color darkHighlight = new Color(200,120,50);
44
private static final Color lightHighlight = darkHighlight.brighter();
45
private static final Color BGCOLOR = Color.blue;
46
47
private static JSplitPane sp;
48
49
public static void main(String[] args) throws Exception {
50
UIManager.setLookAndFeel(new BasicLookAndFeel() {
51
public boolean isSupportedLookAndFeel(){ return true; }
52
public boolean isNativeLookAndFeel(){ return false; }
53
public String getDescription() { return "Foo"; }
54
public String getID() { return "FooID"; }
55
public String getName() { return "FooName"; }
56
});
57
58
SwingUtilities.invokeAndWait(new Runnable() {
59
public void run() {
60
JFrame frame = new JFrame();
61
62
JComponent a = new JPanel();
63
a.setBackground(Color.white);
64
a.setMinimumSize(new Dimension(10, 10));
65
66
JComponent b = new JPanel();
67
b.setBackground(Color.white);
68
b.setMinimumSize(new Dimension(10, 10));
69
70
sp = new JSplitPane(JSplitPane.VERTICAL_SPLIT, a, b);
71
sp.setPreferredSize(new Dimension(20, 20));
72
sp.setBackground(BGCOLOR);
73
74
Border bo = new BasicBorders.SplitPaneBorder(lightHighlight,
75
Color.red);
76
Border ibo = new EmptyBorder(0, 0, 0, 0);
77
sp.setBorder(bo);
78
sp.setMinimumSize(new Dimension(200, 200));
79
80
((BasicSplitPaneUI) sp.getUI()).getDivider().setBorder(ibo);
81
82
frame.getContentPane().setLayout(new FlowLayout());
83
frame.getContentPane().setBackground(darkShadow);
84
frame.getContentPane().add(sp);
85
86
frame.setSize(200, 200);
87
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
88
frame.setVisible(true);
89
}
90
});
91
92
final Robot robot = new Robot();
93
robot.waitForIdle();
94
robot.delay(1000);
95
96
SwingUtilities.invokeAndWait(new Runnable() {
97
public void run() {
98
Rectangle rect = ((BasicSplitPaneUI) sp.getUI()).getDivider().getBounds();
99
100
Point p = rect.getLocation();
101
102
SwingUtilities.convertPointToScreen(p, sp);
103
104
for (int i = 0; i < rect.width; i++) {
105
if (!BGCOLOR.equals(robot.getPixelColor(p.x + i, p.y + rect.height - 1))) {
106
throw new Error("The divider's area has incorrect color.");
107
}
108
}
109
}
110
});
111
}
112
}
113
114