6718964: Swing border tests should be open source
Reviewed-by: peterz
This commit is contained in:
parent
762ea5875b
commit
9d7b3f41e0
43
jdk/test/javax/swing/border/Test4120351.java
Normal file
43
jdk/test/javax/swing/border/Test4120351.java
Normal file
@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright 1999-2008 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 4120351
|
||||
* @summary Tests that the methods createEtchedBorder(int type) and
|
||||
* createEtchedBorder(int type, Color highlight, Color shadows) are added
|
||||
* @author Andrey Pikalev
|
||||
*/
|
||||
|
||||
import java.awt.Color;
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.border.EtchedBorder;
|
||||
|
||||
public class Test4120351 {
|
||||
public static void main(String[] args) {
|
||||
BorderFactory.createEtchedBorder(EtchedBorder.RAISED);
|
||||
BorderFactory.createEtchedBorder(EtchedBorder.LOWERED);
|
||||
BorderFactory.createEtchedBorder(EtchedBorder.RAISED, Color.BLACK, Color.WHITE);
|
||||
BorderFactory.createEtchedBorder(EtchedBorder.LOWERED, Color.WHITE, Color.BLACK);
|
||||
}
|
||||
}
|
38
jdk/test/javax/swing/border/Test4124729.java
Normal file
38
jdk/test/javax/swing/border/Test4124729.java
Normal file
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright 1999-2008 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 4124729
|
||||
* @summary Test that constrtructor LineBorder(?,?,?) is public
|
||||
* @author Andrey Pikalev
|
||||
*/
|
||||
|
||||
import java.awt.Color;
|
||||
import javax.swing.border.LineBorder;
|
||||
|
||||
public class Test4124729 {
|
||||
public static void main(String[] args) {
|
||||
new LineBorder(Color.BLUE, 3, true);
|
||||
}
|
||||
}
|
9
jdk/test/javax/swing/border/Test4243289.html
Normal file
9
jdk/test/javax/swing/border/Test4243289.html
Normal file
@ -0,0 +1,9 @@
|
||||
<html>
|
||||
<body>
|
||||
When applet starts, you'll see a panel with a TitledBorder with title "Panel Title".
|
||||
If this title is overstriken with the border line, test fails, otherwise it passes.
|
||||
|
||||
<applet width="600" height="300" code="Test4243289.class">
|
||||
</applet>
|
||||
</body>
|
||||
</html>
|
52
jdk/test/javax/swing/border/Test4243289.java
Normal file
52
jdk/test/javax/swing/border/Test4243289.java
Normal file
@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright 1999-2008 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 4243289
|
||||
* @summary Tests that TitledBorder do not draw line through its caption
|
||||
* @author Peter Zhelezniakov
|
||||
* @run applet/manual=yesno Test4243289.html
|
||||
*/
|
||||
|
||||
import java.awt.Font;
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.JApplet;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.border.TitledBorder;
|
||||
|
||||
public class Test4243289 extends JApplet {
|
||||
public void init() {
|
||||
Font font = new Font("Dialog", Font.PLAIN, 12); // NON-NLS: the font name
|
||||
TitledBorder border = BorderFactory.createTitledBorder(
|
||||
BorderFactory.createEtchedBorder(),
|
||||
"Panel Title", // NON-NLS: the title of the border
|
||||
TitledBorder.DEFAULT_JUSTIFICATION,
|
||||
TitledBorder.DEFAULT_POSITION,
|
||||
font);
|
||||
|
||||
JPanel panel = new JPanel();
|
||||
panel.setBorder(border);
|
||||
getContentPane().add(panel);
|
||||
}
|
||||
}
|
10
jdk/test/javax/swing/border/Test4247606.html
Normal file
10
jdk/test/javax/swing/border/Test4247606.html
Normal file
@ -0,0 +1,10 @@
|
||||
<html>
|
||||
<body>
|
||||
If the button do not fit into the titled border bounds
|
||||
and cover the bottom border's line then test fails.
|
||||
Otherwise test passes.
|
||||
|
||||
<applet width="200" height="200" code="Test4247606.class">
|
||||
</applet>
|
||||
</body>
|
||||
</html>
|
62
jdk/test/javax/swing/border/Test4247606.java
Normal file
62
jdk/test/javax/swing/border/Test4247606.java
Normal file
@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Copyright 2001-2008 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 4247606
|
||||
* @summary BorderedPane appears wrong with Title Position Below Bottom
|
||||
* @author Andrey Pikalev
|
||||
* @run applet/manual=yesno Test4247606.html
|
||||
*/
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.JApplet;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.border.Border;
|
||||
import javax.swing.border.TitledBorder;
|
||||
|
||||
public class Test4247606 extends JApplet {
|
||||
public void init() {
|
||||
JButton button = new JButton("Button"); // NON-NLS: the button text
|
||||
button.setBorder(BorderFactory.createLineBorder(Color.red, 1));
|
||||
|
||||
TitledBorder border = new TitledBorder("Bordered Pane"); // NON-NLS: the panel title
|
||||
border.setTitlePosition(TitledBorder.BELOW_BOTTOM);
|
||||
|
||||
JPanel panel = create(button, border);
|
||||
panel.setBackground(Color.green);
|
||||
|
||||
getContentPane().add(create(panel, BorderFactory.createEmptyBorder(10, 10, 10, 10)));
|
||||
}
|
||||
|
||||
private static JPanel create(JComponent component, Border border) {
|
||||
JPanel panel = new JPanel(new BorderLayout());
|
||||
panel.setBorder(border);
|
||||
panel.add(component);
|
||||
return panel;
|
||||
}
|
||||
}
|
10
jdk/test/javax/swing/border/Test4252164.html
Normal file
10
jdk/test/javax/swing/border/Test4252164.html
Normal file
@ -0,0 +1,10 @@
|
||||
<html>
|
||||
<body>
|
||||
Please, ensure that rounded border is filled completely.
|
||||
It should not contain white points inside.
|
||||
Use Mouse Wheel to change thickness of the border.
|
||||
|
||||
<applet width="400" height="200" code="Test4252164.class">
|
||||
</applet>
|
||||
</body>
|
||||
</html>
|
73
jdk/test/javax/swing/border/Test4252164.java
Normal file
73
jdk/test/javax/swing/border/Test4252164.java
Normal file
@ -0,0 +1,73 @@
|
||||
/*
|
||||
* Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 4252164
|
||||
* @summary Tests rounded LineBorder for components
|
||||
* @author Sergey Malenkov
|
||||
* @run applet/manual=yesno Test4252164.html
|
||||
*/
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.event.MouseWheelEvent;
|
||||
import java.awt.event.MouseWheelListener;
|
||||
import javax.swing.JApplet;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.border.LineBorder;
|
||||
|
||||
public class Test4252164 extends JApplet implements MouseWheelListener {
|
||||
private int thickness;
|
||||
private JLabel rounded;
|
||||
private JLabel straight;
|
||||
|
||||
public void mouseWheelMoved(MouseWheelEvent event) {
|
||||
update(event.getWheelRotation());
|
||||
}
|
||||
|
||||
public void init() {
|
||||
add(createUI());
|
||||
addMouseWheelListener(this);
|
||||
}
|
||||
|
||||
private JPanel createUI() {
|
||||
this.rounded = new JLabel("ROUNDED"); // NON-NLS: the label for rounded border
|
||||
this.straight = new JLabel("STRAIGHT"); // NON-NLS: the label for straight border
|
||||
|
||||
JPanel panel = new JPanel();
|
||||
panel.add(this.rounded);
|
||||
panel.add(this.straight);
|
||||
|
||||
update(10);
|
||||
|
||||
return panel;
|
||||
}
|
||||
|
||||
private void update(int thickness) {
|
||||
this.thickness += thickness;
|
||||
|
||||
this.rounded.setBorder(new LineBorder(Color.RED, this.thickness, true));
|
||||
this.straight.setBorder(new LineBorder(Color.RED, this.thickness, false));
|
||||
}
|
||||
}
|
57
jdk/test/javax/swing/border/Test6461042.java
Normal file
57
jdk/test/javax/swing/border/Test6461042.java
Normal file
@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright 2006-2008 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 6461042
|
||||
* @summary Tests that toString() doesn't cause StackOverflowException
|
||||
* when a JComponent is its own border
|
||||
* @author Shannon Hickey
|
||||
*/
|
||||
|
||||
import java.awt.Component;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Insets;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.border.Border;
|
||||
|
||||
public class Test6461042 extends JComponent implements Border {
|
||||
public static void main(String[] args) {
|
||||
new Test6461042().toString();
|
||||
}
|
||||
|
||||
public Test6461042() {
|
||||
setBorder(this);
|
||||
}
|
||||
|
||||
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
|
||||
}
|
||||
|
||||
public Insets getBorderInsets(Component c) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean isBorderOpaque() {
|
||||
return false;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user