Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/javax/swing/JSplitPane/4885629/bug4885629.java
41153 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
* @key headful
27
* @bug 4885629
28
* @summary With JSplitPane in VERTICAL_SPLIT, SplitPaneBorder draws bottom edge of divider
29
* @author Andrey Pikalev
30
*/
31
32
import javax.swing.*;
33
import javax.swing.border.Border;
34
import javax.swing.border.EmptyBorder;
35
import javax.swing.plaf.basic.BasicBorders;
36
import javax.swing.plaf.basic.BasicLookAndFeel;
37
import javax.swing.plaf.basic.BasicSplitPaneUI;
38
import java.awt.*;
39
40
41
public class bug4885629 {
42
43
private static final Color darkShadow = new Color(100,120,200);
44
private static final Color darkHighlight = new Color(200,120,50);
45
private static final Color lightHighlight = darkHighlight.brighter();
46
private static final Color BGCOLOR = Color.blue;
47
48
private static JSplitPane sp;
49
private static JFrame frame;
50
51
public static void main(String[] args) throws Exception {
52
UIManager.setLookAndFeel(new BasicLookAndFeel() {
53
public boolean isSupportedLookAndFeel(){ return true; }
54
public boolean isNativeLookAndFeel(){ return false; }
55
public String getDescription() { return "Foo"; }
56
public String getID() { return "FooID"; }
57
public String getName() { return "FooName"; }
58
});
59
60
try {
61
SwingUtilities.invokeAndWait(new Runnable() {
62
public void run() {
63
frame = new JFrame();
64
65
JComponent a = new JPanel();
66
a.setBackground(Color.white);
67
a.setMinimumSize(new Dimension(10, 10));
68
69
JComponent b = new JPanel();
70
b.setBackground(Color.white);
71
b.setMinimumSize(new Dimension(10, 10));
72
73
sp = new JSplitPane(JSplitPane.VERTICAL_SPLIT, a, b);
74
sp.setPreferredSize(new Dimension(20, 20));
75
sp.setBackground(BGCOLOR);
76
77
Border bo = new BasicBorders.SplitPaneBorder(lightHighlight,
78
Color.red);
79
Border ibo = new EmptyBorder(0, 0, 0, 0);
80
sp.setBorder(bo);
81
sp.setMinimumSize(new Dimension(200, 200));
82
83
((BasicSplitPaneUI) sp.getUI()).getDivider().setBorder(ibo);
84
85
frame.getContentPane().setLayout(new FlowLayout());
86
frame.getContentPane().setBackground(darkShadow);
87
frame.getContentPane().add(sp);
88
89
frame.setSize(200, 200);
90
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
91
frame.setVisible(true);
92
}
93
});
94
95
final Robot robot = new Robot();
96
robot.waitForIdle();
97
robot.delay(1000);
98
99
SwingUtilities.invokeAndWait(new Runnable() {
100
public void run() {
101
Rectangle rect = ((BasicSplitPaneUI) sp.getUI()).getDivider().getBounds();
102
103
Point p = rect.getLocation();
104
105
SwingUtilities.convertPointToScreen(p, sp);
106
107
for (int i = 0; i < rect.width; i++) {
108
if (!BGCOLOR.equals(robot.getPixelColor(p.x + i, p.y + rect.height - 1))) {
109
throw new Error("The divider's area has incorrect color.");
110
}
111
}
112
}
113
});
114
} finally {
115
if (frame != null) SwingUtilities.invokeAndWait(() -> frame.dispose());
116
}
117
}
118
}
119
120