Skip to content

Commit 716b87f

Browse files
committed
8352684: Opensource JInternalFrame tests - series1
Backport-of: 66435c27b3e0a89e4350caf6207e36f5a9b82b7f
1 parent ad6f34f commit 716b87f

File tree

4 files changed

+304
-0
lines changed

4 files changed

+304
-0
lines changed
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
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 4131008
27+
* @summary JInternalFrame should refresh title after it changing
28+
* @library /java/awt/regtesthelpers
29+
* @build PassFailJFrame
30+
* @run main/manual bug4131008
31+
*/
32+
33+
import java.awt.event.ActionEvent;
34+
import java.awt.event.ActionListener;
35+
36+
import javax.swing.JButton;
37+
import javax.swing.JDesktopPane;
38+
import javax.swing.JFrame;
39+
import javax.swing.JInternalFrame;
40+
import javax.swing.UIManager;
41+
42+
public class bug4131008 {
43+
44+
private static final String INSTRUCTIONS = """
45+
Press button "Change title" at the internal frame "Old".
46+
If title of this frame will replaced by "New",
47+
then test passed, else test fails.""";
48+
49+
public static void main(String[] args) throws Exception {
50+
51+
UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel");
52+
53+
PassFailJFrame.builder()
54+
.title("bug4131008 Instructions")
55+
.instructions(INSTRUCTIONS)
56+
.columns(50)
57+
.testUI(bug4131008::createTestUI)
58+
.build()
59+
.awaitAndCheck();
60+
}
61+
62+
private static JFrame createTestUI() {
63+
JFrame frame = new JFrame("bug4131008");
64+
JInternalFrame jif = new JInternalFrame("Old");
65+
JDesktopPane jdp = new JDesktopPane();
66+
frame.setContentPane(jdp);
67+
68+
jif.setSize(150, 100);
69+
jif.setVisible(true);
70+
JButton bt = new JButton("Change title");
71+
bt.addActionListener(new ActionListener() {
72+
public void actionPerformed(ActionEvent e) {
73+
jif.setTitle("New");
74+
}
75+
});
76+
jif.getContentPane().add(bt);
77+
jdp.add(jif);
78+
try {
79+
jif.setSelected(true);
80+
} catch (Exception e) {
81+
throw new RuntimeException(e);
82+
}
83+
frame.setSize(300, 200);
84+
return frame;
85+
}
86+
}
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
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 4176136
27+
* @summary Default close operation JInternalFrame.DO_NOTHING_ON_CLOSE works correctly
28+
* @library /java/awt/regtesthelpers
29+
* @build PassFailJFrame
30+
* @run main/manual bug4176136
31+
*/
32+
33+
34+
import javax.swing.JDesktopPane;
35+
import javax.swing.JFrame;
36+
import javax.swing.JInternalFrame;
37+
38+
public class bug4176136 {
39+
40+
private static final String INSTRUCTIONS = """
41+
Click the close button of the internal frame.
42+
You will see the close button activate,
43+
but nothing else should happen.
44+
If the internal frame closes, the test fails.
45+
If it doesn't close, the test passes.""";
46+
47+
public static void main(String[] args) throws Exception {
48+
PassFailJFrame.builder()
49+
.title("bug4176136 Instructions")
50+
.instructions(INSTRUCTIONS)
51+
.columns(25)
52+
.testUI(bug4176136::createTestUI)
53+
.build()
54+
.awaitAndCheck();
55+
}
56+
57+
private static JFrame createTestUI() {
58+
JFrame frame = new JFrame("bug4176136");
59+
JDesktopPane dp = new JDesktopPane();
60+
frame.add(dp);
61+
JInternalFrame inf = new JInternalFrame();
62+
dp.add(inf);
63+
inf.setDefaultCloseOperation(JInternalFrame.DO_NOTHING_ON_CLOSE);
64+
inf.setSize(100, 100);
65+
inf.setClosable(true);
66+
inf.setVisible(true);
67+
frame.setSize(200, 200);
68+
return frame;
69+
}
70+
}
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
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 4244536
27+
* @summary Tests that Motif JInternalFrame can be maximized
28+
* after it was iconified.
29+
* @library /java/awt/regtesthelpers
30+
* @build PassFailJFrame
31+
* @run main/manual bug4244536
32+
*/
33+
34+
import javax.swing.JDesktopPane;
35+
import javax.swing.JFrame;
36+
import javax.swing.JInternalFrame;
37+
import javax.swing.UIManager;
38+
39+
public class bug4244536 {
40+
41+
private static final String INSTRUCTIONS = """
42+
Minimize the internal frame using the minimize button.
43+
Then double-click on it to restore its size.
44+
Then press the maximize button.
45+
If the frame gets maximized, test passes.
46+
If its size don't change, test fails.""";
47+
48+
public static void main(String[] args) throws Exception {
49+
UIManager.setLookAndFeel(
50+
"com.sun.java.swing.plaf.motif.MotifLookAndFeel");
51+
52+
PassFailJFrame.builder()
53+
.title("bug4244536 Instructions")
54+
.instructions(INSTRUCTIONS)
55+
.columns(50)
56+
.testUI(bug4244536::createTestUI)
57+
.build()
58+
.awaitAndCheck();
59+
}
60+
61+
private static JFrame createTestUI() {
62+
JFrame frame = new JFrame("bug4244536");
63+
JDesktopPane desktop = new JDesktopPane();
64+
JInternalFrame jif = new JInternalFrame("Internal Frame");
65+
jif.setSize(150, 150);
66+
jif.setMaximizable(true);
67+
jif.setIconifiable(true);
68+
jif.setVisible(true);
69+
desktop.add(jif);
70+
frame.add("Center", desktop);
71+
frame.setSize(300, 300);
72+
return frame;
73+
}
74+
75+
}
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
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 4305284
27+
* @summary JInternalFrames can't be sized off of the desktop
28+
* @library /java/awt/regtesthelpers
29+
* @build PassFailJFrame
30+
* @run main/manual bug4305284
31+
*/
32+
33+
import javax.swing.JDesktopPane;
34+
import javax.swing.JFrame;
35+
import javax.swing.JInternalFrame;
36+
37+
public class bug4305284 {
38+
39+
private static final String INSTRUCTIONS = """
40+
Try to resize the shown internal frame.
41+
If it can't be sized of the desktop bounds,
42+
then test passes, else test fails.""";
43+
44+
public static void main(String[] args) throws Exception {
45+
PassFailJFrame.builder()
46+
.title("bug4305284 Instructions")
47+
.instructions(INSTRUCTIONS)
48+
.columns(25)
49+
.testUI(bug4305284::createTestUI)
50+
.build()
51+
.awaitAndCheck();
52+
}
53+
54+
private static JFrame createTestUI() {
55+
JFrame frame = new JFrame("bug4305284");
56+
JInternalFrame jif = new JInternalFrame("Test",
57+
true, true, true, true);
58+
JDesktopPane dp = new JDesktopPane();
59+
frame.setContentPane(dp);
60+
dp.add(jif);
61+
62+
try {
63+
jif.setBounds(50, 50, 200, 200);
64+
jif.setMaximum(false);
65+
jif.setVisible(true);
66+
} catch (Exception e) {
67+
e.printStackTrace();
68+
}
69+
frame.setSize(300, 300);
70+
return frame;
71+
}
72+
73+
}

0 commit comments

Comments
 (0)