Skip to content

Commit da3bb06

Browse files
committed
8352685: Opensource JInternalFrame tests - series2
Reviewed-by: azvegint
1 parent d809033 commit da3bb06

File tree

5 files changed

+379
-0
lines changed

5 files changed

+379
-0
lines changed

test/jdk/ProblemList.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -780,6 +780,7 @@ javax/swing/JColorChooser/8065098/bug8065098.java 8065647 macosx-all
780780
javax/swing/JTabbedPane/4666224/bug4666224.java 8144124 macosx-all
781781
javax/swing/JTabbedPane/TestJTabbedPaneOpaqueColor.java 8345090 windows-all,linux-all
782782
javax/swing/SwingUtilities/TestTextPosInPrint.java 8227025 windows-all
783+
javax/swing/JInternalFrame/bug4134077.java 8184985 windows-all
783784

784785
java/awt/event/MouseEvent/SpuriousExitEnter/SpuriousExitEnter_1.java 7131438,8022539 generic-all
785786
java/awt/event/MouseEvent/SpuriousExitEnter/SpuriousExitEnter_2.java 7131438,8022539 generic-all
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
/*
2+
* Copyright (c) 1999, 2025, 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 4130806
27+
* @summary JInternalFrame's setIcon(true) works correctly
28+
* @library /java/awt/regtesthelpers
29+
* @build PassFailJFrame
30+
* @run main/manual bug4130806
31+
*/
32+
33+
import javax.swing.JDesktopPane;
34+
import javax.swing.JFrame;
35+
import javax.swing.JInternalFrame;
36+
import java.beans.PropertyVetoException;
37+
38+
public class bug4130806 {
39+
40+
private static final String INSTRUCTIONS = """
41+
If an icon is visible for the iconified internalframe, the test passes.
42+
Otherwise, the test fails.""";
43+
44+
public static void main(String[] args) throws Exception {
45+
PassFailJFrame.builder()
46+
.title("bug4130806 Instructions")
47+
.instructions(INSTRUCTIONS)
48+
.columns(35)
49+
.testUI(bug4130806::createTestUI)
50+
.build()
51+
.awaitAndCheck();
52+
}
53+
54+
private static JFrame createTestUI() {
55+
JFrame frame = new JFrame("bug4130806");
56+
JDesktopPane mDesktop = new JDesktopPane();
57+
frame.add(mDesktop);
58+
frame.pack();
59+
JInternalFrame jif = new JInternalFrame("My Frame");
60+
jif.setIconifiable(true);
61+
mDesktop.add(jif);
62+
jif.setBounds(50,50,100,100);
63+
try {
64+
jif.setIcon(true);
65+
} catch (PropertyVetoException e) {
66+
throw new RuntimeException("PropertyVetoException received");
67+
}
68+
jif.setVisible(true);
69+
frame.setSize(200, 200);
70+
return frame;
71+
}
72+
}
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
/*
2+
* Copyright (c) 2000, 2025, 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 4134077
27+
* @requires (os.family == "windows")
28+
* @summary Metal,Window:If JInternalFrame's title text is long last must be ellipsis
29+
* @library /java/awt/regtesthelpers
30+
* @build PassFailJFrame
31+
* @run main/manual bug4134077
32+
*/
33+
34+
import java.awt.BorderLayout;
35+
import java.awt.ComponentOrientation;
36+
import java.awt.event.ActionEvent;
37+
import java.awt.event.ActionListener;
38+
import javax.swing.JButton;
39+
import javax.swing.JDesktopPane;
40+
import javax.swing.JFrame;
41+
import javax.swing.JInternalFrame;
42+
import javax.swing.JPanel;
43+
import javax.swing.SwingUtilities;
44+
import javax.swing.UIManager;
45+
import javax.swing.UnsupportedLookAndFeelException;
46+
47+
public class bug4134077 {
48+
49+
private static JFrame frame;
50+
51+
private static final String INSTRUCTIONS = """
52+
Try to resize internal frame with diferrent combinations of
53+
LookAndFeels and title pane's buttons and orientation.
54+
55+
The internal frame's title should clip if its too long to
56+
be entierly visible (ends by "...")
57+
and window can never be
58+
smaller than the width of the first two letters of the title
59+
plus "...".""";
60+
61+
public static void main(String[] args) throws Exception {
62+
PassFailJFrame.builder()
63+
.title("bug4134077 Instructions")
64+
.instructions(INSTRUCTIONS)
65+
.columns(35)
66+
.testUI(bug4134077::createTestUI)
67+
.build()
68+
.awaitAndCheck();
69+
}
70+
71+
private static void setLF(ActionEvent e) {
72+
try {
73+
UIManager.setLookAndFeel(((JButton)e.getSource()).getActionCommand());
74+
SwingUtilities.updateComponentTreeUI(frame);
75+
} catch (ClassNotFoundException | InstantiationException
76+
| UnsupportedLookAndFeelException
77+
| IllegalAccessException ex) {
78+
throw new RuntimeException(ex);
79+
}
80+
}
81+
82+
private static JFrame createTestUI() {
83+
frame = new JFrame("bug4134077");
84+
JDesktopPane jdp = new JDesktopPane();
85+
frame.add(jdp);
86+
87+
final JInternalFrame jif =
88+
new JInternalFrame("Very Long Title For Internal Frame", true);
89+
jdp.add(jif);
90+
jif.setSize(150,150);
91+
jif.setLocation(150, 50);
92+
jif.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
93+
jif.setVisible(true);
94+
95+
JPanel p = new JPanel();
96+
97+
JButton metal = new JButton("Metal");
98+
metal.setActionCommand("javax.swing.plaf.metal.MetalLookAndFeel");
99+
metal.addActionListener((ActionEvent e) -> setLF(e));
100+
p.add(metal);
101+
102+
JButton windows = new JButton("Windows");
103+
windows.setActionCommand("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
104+
windows.addActionListener((ActionEvent e) -> setLF(e));
105+
p.add(windows);
106+
107+
JButton orientation = new JButton("Change orientation");
108+
orientation.addActionListener(e -> {
109+
jif.setComponentOrientation(
110+
jif.getComponentOrientation() == ComponentOrientation.LEFT_TO_RIGHT
111+
? ComponentOrientation.RIGHT_TO_LEFT
112+
: ComponentOrientation.LEFT_TO_RIGHT);
113+
});
114+
p.add(orientation);
115+
116+
JButton clo = new JButton("Closable");
117+
clo.addActionListener(e -> jif.setClosable(!jif.isClosable()));
118+
p.add(clo);
119+
120+
JButton ico = new JButton("Iconifiable");
121+
ico.addActionListener(e -> jif.setIconifiable(!jif.isIconifiable()));
122+
p.add(ico);
123+
124+
JButton max = new JButton("Maximizable");
125+
max.addActionListener(e -> jif.setMaximizable(!jif.isMaximizable()));
126+
p.add(max);
127+
128+
frame.add(p, BorderLayout.SOUTH);
129+
frame.setSize(700, 300);
130+
return frame;
131+
}
132+
}
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
/*
2+
* Copyright (c) 2000, 2025, 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 4193070
27+
* @summary Tests correct mouse pointer shape
28+
* @requires (os.family != "mac")
29+
* @library /java/awt/regtesthelpers
30+
* @build PassFailJFrame
31+
* @run main/manual bug4193070
32+
*/
33+
34+
import java.awt.Dimension;
35+
import javax.swing.JDesktopPane;
36+
import javax.swing.JFrame;
37+
import javax.swing.JInternalFrame;
38+
39+
public class bug4193070 {
40+
41+
private static final String INSTRUCTIONS = """
42+
Two internal frame will be shown. Select any internal frame;
43+
Move mouse pointer inside the selected internal frame,
44+
then to border of internal frame.
45+
Mouse pointer should take the shape of resize cursor.
46+
Now slowly move the mouse back inside the internal frame.
47+
If mouse pointer shape does not change back to
48+
normal shape of mouse pointer, then test failed.
49+
Now try fast resizing an internal frame.
50+
Check that mouse pointer always has resize shape,
51+
even when it goes over other internal frame.
52+
If during resizing mouse pointer shape changes,
53+
then test failed. Otherwise test succeded.""";
54+
55+
public static void main(String[] args) throws Exception {
56+
PassFailJFrame.builder()
57+
.title("bug4193070 Instructions")
58+
.instructions(INSTRUCTIONS)
59+
.columns(35)
60+
.testUI(bug4193070::createTestUI)
61+
.build()
62+
.awaitAndCheck();
63+
}
64+
65+
private static JFrame createTestUI() {
66+
JFrame f = new JFrame("bug4193070");
67+
JDesktopPane dp = new JDesktopPane();
68+
69+
JInternalFrame intFrm1 = new JInternalFrame();
70+
intFrm1.setResizable(true);
71+
dp.add(intFrm1);
72+
73+
JInternalFrame intFrm2 = new JInternalFrame();
74+
intFrm2.setResizable(true);
75+
dp.add(intFrm2);
76+
77+
f.setContentPane(dp);
78+
f.setSize(new Dimension(500, 275));
79+
80+
intFrm1.setBounds(25, 25, 200, 200);
81+
intFrm1.show();
82+
83+
intFrm2.setBounds(275, 25, 200, 200);
84+
intFrm2.show();
85+
return f;
86+
}
87+
}
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
/*
2+
* Copyright (c) 2000, 2025, 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 4225701
27+
* @summary Verifies MetalInternalFrameUI.installKeyboardActions
28+
* doesn't install listener
29+
* @library /java/awt/regtesthelpers
30+
* @build PassFailJFrame
31+
* @run main/manual bug4225701
32+
*/
33+
34+
import javax.swing.JDesktopPane;
35+
import javax.swing.JFrame;
36+
import javax.swing.JInternalFrame;
37+
38+
public class bug4225701 {
39+
40+
private static final String INSTRUCTIONS = """
41+
Give a focus to the internal frame "Frame 4" and press Ctrl-F4.
42+
The "Frame 4" should be closed. Give a focus to the internal
43+
frame "Frame 1" and press Ctrl-F4.
44+
If "Frame 4" and "Frame 1" is not closed, then press Fail else press Pass.""";
45+
46+
public static void main(String[] args) throws Exception {
47+
PassFailJFrame.builder()
48+
.title("bug4225701 Instructions")
49+
.instructions(INSTRUCTIONS)
50+
.columns(35)
51+
.testUI(bug4225701::createTestUI)
52+
.build()
53+
.awaitAndCheck();
54+
}
55+
56+
private static JFrame createTestUI() {
57+
58+
JFrame frame = new JFrame("bug4225701");
59+
JInternalFrame jif1 = new JInternalFrame("Frame 1", true, true, true, true);
60+
JInternalFrame jif2 = new JInternalFrame("Frame 2", false);
61+
JInternalFrame jif3 = new JInternalFrame("Frame 3", false);
62+
JInternalFrame jif4 = new JInternalFrame("Frame 4", true, true, true, true);
63+
JDesktopPane jdp = new JDesktopPane();
64+
65+
frame.setContentPane(jdp);
66+
67+
jdp.add(jif1);
68+
jif1.setBounds(0, 150, 150, 150);
69+
jif1.setVisible(true);
70+
71+
jdp.add(jif2);
72+
jif2.setBounds(100, 100, 150, 150);
73+
jif2.setVisible(true);
74+
75+
jdp.add(jif3);
76+
jif3.setBounds(200, 50, 150, 150);
77+
jif3.setVisible(true);
78+
79+
jdp.add(jif4);
80+
jif4.setBounds(300, 0, 150, 150);
81+
jif4.setVisible(true);
82+
83+
frame.setSize(500, 500);
84+
return frame;
85+
}
86+
87+
}

0 commit comments

Comments
 (0)