Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/java/beans/XMLEncoder/Test6437265.java
41152 views
1
/*
2
* Copyright (c) 2006, 2007, 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 6437265
27
* @summary Tests encoding of container with BorderLayout
28
* @run main/othervm -Djava.security.manager=allow Test6437265
29
* @author Sergey Malenkov
30
*/
31
32
import java.awt.BorderLayout;
33
import java.awt.Component;
34
import javax.swing.JLabel;
35
import javax.swing.JPanel;
36
37
public final class Test6437265 extends AbstractTest<JPanel> {
38
private static final String[] NAMES = {
39
BorderLayout.EAST,
40
BorderLayout.WEST,
41
BorderLayout.NORTH,
42
BorderLayout.SOUTH,
43
BorderLayout.CENTER,
44
BorderLayout.LINE_END,
45
BorderLayout.PAGE_END,
46
BorderLayout.LINE_START,
47
BorderLayout.PAGE_START};
48
49
public static void main(String[] args) {
50
new Test6437265().test(true);
51
}
52
53
protected JPanel getObject() {
54
JPanel panel = new MyPanel();
55
for (String name : NAMES) {
56
panel.add(name, new JLabel(name));
57
}
58
return panel;
59
}
60
61
protected void validate(JPanel before, JPanel after) {
62
validate(before);
63
validate(after);
64
super.validate(before, after);
65
}
66
67
private static void validate(JPanel panel) {
68
BorderLayout layout = (BorderLayout) panel.getLayout();
69
for (Component component : panel.getComponents()) {
70
String name = (String) layout.getConstraints(component);
71
if (name == null)
72
throw new Error("The component is not layed out: " + component);
73
74
JLabel label = (JLabel) component;
75
if (!name.equals(label.getText()))
76
throw new Error("The component is layed out on " + name + ": " + component);
77
}
78
}
79
80
public static final class MyPanel extends JPanel {
81
public MyPanel() {
82
// the bug is reproducible for containers
83
// that uses BorderLayout as default layout manager.
84
super(new BorderLayout(3, 3));
85
}
86
}
87
}
88
89