8340279: Open source several AWT Dialog tests - Batch 2
Reviewed-by: abhiscxk, prr
This commit is contained in:
parent
f6fe5eaf1a
commit
e0dabfb4bf
@ -478,6 +478,8 @@ java/awt/KeyboardFocusmanager/ConsumeNextMnemonicKeyTypedTest/ConsumeNextMnemoni
|
||||
|
||||
java/awt/Window/GetScreenLocation/GetScreenLocationTest.java 8225787 linux-x64
|
||||
java/awt/Dialog/MakeWindowAlwaysOnTop/MakeWindowAlwaysOnTop.java 8266243 macosx-aarch64
|
||||
java/awt/Dialog/PrintToFileTest/PrintToFileRevoked.java 8029249 macosx-all
|
||||
java/awt/Dialog/PrintToFileTest/PrintToFileGranted.java 8029249 macosx-all
|
||||
java/awt/Dialog/ChoiceModalDialogTest.java 8161475 macosx-all
|
||||
java/awt/Dialog/FileDialogUserFilterTest.java 8001142 generic-all
|
||||
|
||||
|
122
test/jdk/java/awt/Dialog/DialogSystemMenu/DialogSystemMenu.java
Normal file
122
test/jdk/java/awt/Dialog/DialogSystemMenu/DialogSystemMenu.java
Normal file
@ -0,0 +1,122 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2024, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
import java.awt.Dialog;
|
||||
import java.awt.Frame;
|
||||
import java.awt.event.WindowListener;
|
||||
import java.util.List;
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 4058953 4094035
|
||||
* @summary Test to verify system menu of a dialog on win32
|
||||
* @requires (os.family == "windows")
|
||||
* @library /java/awt/regtesthelpers
|
||||
* @build PassFailJFrame
|
||||
* @run main/manual DialogSystemMenu
|
||||
*/
|
||||
|
||||
public class DialogSystemMenu {
|
||||
public static void main(String[] args) throws Exception {
|
||||
String INSTRUCTIONS = """
|
||||
1. Check the following on the first dialog window:
|
||||
Right-clicking on the title bar
|
||||
should bring up a system menu.
|
||||
The system menu should not allow any
|
||||
of the Maximize, Minimize and
|
||||
Restore actions
|
||||
|
||||
2. The second dialog should be non-resizable
|
||||
and have no application icon.
|
||||
""";
|
||||
PassFailJFrame.builder()
|
||||
.title("Test Instructions")
|
||||
.instructions(INSTRUCTIONS)
|
||||
.rows((int) INSTRUCTIONS.lines().count() + 2)
|
||||
.columns(35)
|
||||
.testUI(initialize())
|
||||
.build()
|
||||
.awaitAndCheck();
|
||||
}
|
||||
|
||||
public static List<Dialog> initialize() {
|
||||
Frame frame = new java.awt.Frame("Parent Frame");
|
||||
String txt = """
|
||||
This is a resizable dialog
|
||||
Right-clicking on the title bar
|
||||
should bring up a system menu
|
||||
The system menu should not
|
||||
allow any
|
||||
of the Maximize, Minimize and
|
||||
Restore actions
|
||||
""";
|
||||
String txt_non = """
|
||||
This is a non-resizable dialog
|
||||
It should be really non-resizable
|
||||
and have no application icon
|
||||
""";
|
||||
TestApp resizable = new TestApp(frame, "Test for 4058953", txt, true);
|
||||
resizable.setLocation(0, 0);
|
||||
|
||||
TestApp non_resizable = new TestApp(frame, "Test for 4094035", txt_non, false);
|
||||
non_resizable.setLocation(320, 0);
|
||||
return List.of(resizable, non_resizable);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class TestApp extends Dialog implements WindowListener {
|
||||
public TestApp(java.awt.Frame parent, String title, String txt, boolean resize) {
|
||||
super(parent, title, false);
|
||||
|
||||
java.awt.TextArea ta = new java.awt.TextArea(txt);
|
||||
ta.setEditable(false);
|
||||
this.add(ta, "Center");
|
||||
this.addWindowListener(this);
|
||||
this.setSize(300, 200);
|
||||
this.setResizable(resize);
|
||||
}
|
||||
|
||||
|
||||
public void windowOpened(java.awt.event.WindowEvent myEvent) {
|
||||
}
|
||||
|
||||
public void windowClosed(java.awt.event.WindowEvent myEvent) {
|
||||
}
|
||||
|
||||
public void windowIconified(java.awt.event.WindowEvent myEvent) {
|
||||
}
|
||||
|
||||
public void windowDeiconified(java.awt.event.WindowEvent myEvent) {
|
||||
}
|
||||
|
||||
public void windowActivated(java.awt.event.WindowEvent myEvent) {
|
||||
}
|
||||
|
||||
public void windowDeactivated(java.awt.event.WindowEvent myEvent) {
|
||||
}
|
||||
|
||||
public void windowClosing(java.awt.event.WindowEvent myEvent) {
|
||||
this.dispose();
|
||||
}
|
||||
}
|
BIN
test/jdk/java/awt/Dialog/DialogSystemMenu/icon24x24.gif
Normal file
BIN
test/jdk/java/awt/Dialog/DialogSystemMenu/icon24x24.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 108 B |
BIN
test/jdk/java/awt/Dialog/DialogSystemMenu/iconone.gif
Normal file
BIN
test/jdk/java/awt/Dialog/DialogSystemMenu/iconone.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 109 B |
BIN
test/jdk/java/awt/Dialog/DialogSystemMenu/icontwo.gif
Normal file
BIN
test/jdk/java/awt/Dialog/DialogSystemMenu/icontwo.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 109 B |
68
test/jdk/java/awt/Dialog/FileDialogFilterTest.java
Normal file
68
test/jdk/java/awt/Dialog/FileDialogFilterTest.java
Normal file
@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2024, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
import java.awt.FileDialog;
|
||||
import java.awt.Frame;
|
||||
import java.io.File;
|
||||
import java.io.FilenameFilter;
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 4364256
|
||||
* @summary Test to File Dialog filter
|
||||
* @requires (os.family == "windows")
|
||||
* @library /java/awt/regtesthelpers
|
||||
* @build PassFailJFrame
|
||||
* @run main/manual FileDialogFilterTest
|
||||
*/
|
||||
|
||||
public class FileDialogFilterTest {
|
||||
public static void main(String[] args) throws Exception {
|
||||
String INSTRUCTIONS = """
|
||||
Run the test, make sure a file dialog
|
||||
comes up with no crash. If the file dialog
|
||||
comes up successfully then press PASS, else FAIL.
|
||||
""";
|
||||
PassFailJFrame.builder()
|
||||
.title("Test Instructions")
|
||||
.instructions(INSTRUCTIONS)
|
||||
.rows((int) INSTRUCTIONS.lines().count() + 2)
|
||||
.columns(35)
|
||||
.testUI(initialize())
|
||||
.build()
|
||||
.awaitAndCheck();
|
||||
}
|
||||
|
||||
public static FileDialog initialize() {
|
||||
FileDialog fDlg = new FileDialog(new Frame());
|
||||
fDlg.addNotify();
|
||||
fDlg.setFilenameFilter(new MyFilter());
|
||||
return fDlg;
|
||||
}
|
||||
}
|
||||
|
||||
class MyFilter implements FilenameFilter {
|
||||
public boolean accept(File dir, String name) {
|
||||
return true;
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
import java.awt.Button;
|
||||
import java.awt.FlowLayout;
|
||||
import java.awt.Frame;
|
||||
import java.awt.PrintJob;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
class PrintToFileFrame extends Frame implements ActionListener {
|
||||
Button nativeDlg = new Button("Show print dialog");
|
||||
|
||||
public PrintToFileFrame() {
|
||||
this.setLayout(new FlowLayout());
|
||||
add(nativeDlg);
|
||||
nativeDlg.addActionListener(this);
|
||||
|
||||
setSize(300, 300);
|
||||
}
|
||||
|
||||
@SuppressWarnings("removal")
|
||||
public void actionPerformed(ActionEvent ae) {
|
||||
if (System.getSecurityManager() == null) {
|
||||
throw new RuntimeException("Security manager isn't installed.");
|
||||
}
|
||||
|
||||
try {
|
||||
System.getSecurityManager().checkPrintJobAccess();
|
||||
System.out.println("checkPrintJobAccess - OK");
|
||||
} catch (SecurityException e) {
|
||||
System.out.println("checkPrintJobAccess - ERROR " + e);
|
||||
}
|
||||
|
||||
PrintJob printJob = getToolkit().getPrintJob(this, null, null);
|
||||
|
||||
if (printJob != null) {
|
||||
System.out.println("Print Job: " + printJob);
|
||||
} else {
|
||||
System.out.println("Print Job is null.");
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,70 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2024, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
import java.awt.print.PrinterJob;
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 6275359
|
||||
* @summary Test to verify system menu of a dialog on win32
|
||||
* @requires (os.family == "windows")
|
||||
* @library /java/awt/regtesthelpers
|
||||
* @build PassFailJFrame
|
||||
* @compile PrintToFileFrame.java
|
||||
* @compile PrintToFileGranted.java
|
||||
* @run main/manual/policy=granted/othervm PrintToFileGranted
|
||||
*/
|
||||
|
||||
public class PrintToFileGranted {
|
||||
public static void main(String[] args) throws Exception {
|
||||
String INSTRUCTIONS;
|
||||
if (isPrintSupport()) {
|
||||
INSTRUCTIONS = """
|
||||
1. Click on 'Show file dialog' button A print dialog will come up
|
||||
2. If checkbox 'Print to file' is enabled then the test passed
|
||||
else the test failed
|
||||
3. Close the print dialog before pressing PASS or FAIL buttons
|
||||
""";
|
||||
} else {
|
||||
INSTRUCTIONS = """
|
||||
1. The test requires printer installed in your system,
|
||||
but there is no printers found
|
||||
Please install one and re-run the test
|
||||
""";
|
||||
}
|
||||
|
||||
PassFailJFrame.builder()
|
||||
.title("Test Instructions")
|
||||
.instructions(INSTRUCTIONS)
|
||||
.rows((int) INSTRUCTIONS.lines().count() + 2)
|
||||
.columns(35)
|
||||
.testUI(new PrintToFileFrame())
|
||||
.build()
|
||||
.awaitAndCheck();
|
||||
}
|
||||
|
||||
public static boolean isPrintSupport() {
|
||||
PrinterJob pj = PrinterJob.getPrinterJob();
|
||||
return pj.getPrintService() != null;
|
||||
}
|
||||
}
|
@ -0,0 +1,69 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2024, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
import java.awt.print.PrinterJob;
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 6275359
|
||||
* @summary Test to verify Printing ignores Security permissions
|
||||
* using native dialog
|
||||
* @requires (os.family == "windows")
|
||||
* @library /java/awt/regtesthelpers
|
||||
* @build PassFailJFrame
|
||||
* @compile PrintToFileRevoked.java
|
||||
* @run main/manual/policy=revoked/othervm PrintToFileRevoked
|
||||
*/
|
||||
|
||||
public class PrintToFileRevoked {
|
||||
public static void main(String[] args) throws Exception {
|
||||
String INSTRUCTIONS;
|
||||
if (isPrintSupport()) {
|
||||
INSTRUCTIONS = """
|
||||
1. Click on 'Show file dialog' button A print dialog will come up
|
||||
2. If checkbox 'Print to file' is disabled then the test passed
|
||||
else the test failed
|
||||
3. Close the print dialog before pressing PASS or FAIL buttons
|
||||
""";
|
||||
} else {
|
||||
INSTRUCTIONS = """
|
||||
1. The test requires printer installed in your system,
|
||||
but there is no printers found
|
||||
Please install one and re-run the test
|
||||
""";
|
||||
}
|
||||
PassFailJFrame.builder()
|
||||
.title("Test Instructions")
|
||||
.instructions(INSTRUCTIONS)
|
||||
.rows((int) INSTRUCTIONS.lines().count() + 2)
|
||||
.columns(35)
|
||||
.testUI(new PrintToFileFrame())
|
||||
.build()
|
||||
.awaitAndCheck();
|
||||
}
|
||||
|
||||
public static boolean isPrintSupport() {
|
||||
PrinterJob pj = PrinterJob.getPrinterJob();
|
||||
return pj.getPrintService() != null;
|
||||
}
|
||||
}
|
10
test/jdk/java/awt/Dialog/PrintToFileTest/granted
Normal file
10
test/jdk/java/awt/Dialog/PrintToFileTest/granted
Normal file
@ -0,0 +1,10 @@
|
||||
/* AUTOMATICALLY GENERATED ON Thu Jan 03 15:48:39 PST 2002*/
|
||||
/* DO NOT EDIT */
|
||||
|
||||
grant {
|
||||
permission java.lang.RuntimePermission "queuePrintJob";
|
||||
permission java.util.PropertyPermission "*", "read";
|
||||
permission java.io.FilePermission "<<ALL FILES>>", "read";
|
||||
permission java.io.FilePermission "<<ALL FILES>>", "write";
|
||||
permission java.lang.RuntimePermission "accessClassInPackage.sun.util.locale.provider";
|
||||
};
|
9
test/jdk/java/awt/Dialog/PrintToFileTest/revoked
Normal file
9
test/jdk/java/awt/Dialog/PrintToFileTest/revoked
Normal file
@ -0,0 +1,9 @@
|
||||
/* AUTOMATICALLY GENERATED ON Thu Jan 03 15:48:39 PST 2002*/
|
||||
/* DO NOT EDIT */
|
||||
|
||||
grant {
|
||||
permission java.lang.RuntimePermission "queuePrintJob";
|
||||
permission java.util.PropertyPermission "*", "read";
|
||||
permission java.lang.RuntimePermission "accessClassInPackage.sun.util.locale.provider";
|
||||
};
|
||||
|
152
test/jdk/java/awt/Dialog/TopmostModalDialogTest.java
Normal file
152
test/jdk/java/awt/Dialog/TopmostModalDialogTest.java
Normal file
@ -0,0 +1,152 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2024, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
import java.awt.Button;
|
||||
import java.awt.Dialog;
|
||||
import java.awt.Frame;
|
||||
import java.awt.GridLayout;
|
||||
import java.awt.Window;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.WindowAdapter;
|
||||
import java.awt.event.WindowEvent;
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 4940645
|
||||
* @summary Test to verify setAlwaysOnTop(true) does
|
||||
* work in modal dialog in Windows
|
||||
* @requires (os.family == "windows" | os.family == "linux" )
|
||||
* @library /java/awt/regtesthelpers
|
||||
* @build PassFailJFrame
|
||||
* @run main/manual TopmostModalDialogTest
|
||||
*/
|
||||
|
||||
public class TopmostModalDialogTest {
|
||||
public static void main(String[] args) throws Exception {
|
||||
String INSTRUCTIONS = """
|
||||
(This test verifies that modal dialog can be made always on top
|
||||
This test should only be run on the platforms which support always-on-top windows
|
||||
Such platforms are: Windows, Linux with GNOME2/Metacity window manager,
|
||||
Solaris with GNOME2/Metacity window manager
|
||||
If you are not running on any of these platforms, please select 'Pass' to skip testing
|
||||
If you are unsure on which platform you are running please select 'Pass')
|
||||
|
||||
1. After test started you see a frame with \\"Main Frame\\" title
|
||||
It contains three buttons. Every button starts one of test stage
|
||||
You should test all three stages
|
||||
2. After you press button to start the stage. It shows modal dialog
|
||||
This modal dialog should be always-on-top window
|
||||
3. Since it's a modal the only way to test this is try to cover it
|
||||
using some native window
|
||||
4. If you will able to cover it be native window - test FAILS, otherwise - PASS
|
||||
|
||||
Note: in stages #2 and #3 dialog is initially shown as regular modal dialogs
|
||||
You will see \\"Let's wait\\" message in the message area below
|
||||
Please wait until message \\"Let's make it topmost\\" will be printed in the area
|
||||
After that you can continue testing.
|
||||
""";
|
||||
PassFailJFrame.builder()
|
||||
.title("Test Instructions")
|
||||
.instructions(INSTRUCTIONS)
|
||||
.rows((int) INSTRUCTIONS.lines().count() + 2)
|
||||
.columns(35)
|
||||
.testUI(initialize())
|
||||
.logArea(8)
|
||||
.build()
|
||||
.awaitAndCheck();
|
||||
}
|
||||
|
||||
public static Frame initialize() {
|
||||
final Tester tester = new Tester();
|
||||
Frame frame = new Frame("Main Frame");
|
||||
frame.setLayout(new GridLayout(3, 1));
|
||||
for (int i = 0; i < 3; i++) {
|
||||
Button btn = new Button("Stage #" + i);
|
||||
frame.add(btn);
|
||||
btn.addActionListener(tester);
|
||||
}
|
||||
frame.pack();
|
||||
return frame;
|
||||
}
|
||||
}
|
||||
|
||||
class Tester implements ActionListener {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
String command = e.getActionCommand();
|
||||
PassFailJFrame.log(command);
|
||||
int cmd = Integer.parseInt(command.substring(command.length() - 1));
|
||||
PassFailJFrame.log("" + cmd);
|
||||
Dialog dlg = new Dialog(new Frame(""), "Modal Dialog", true);
|
||||
dlg.setBounds(100, 100, 100, 100);
|
||||
dlg.addWindowListener(new WindowAdapter() {
|
||||
public void windowClosing(WindowEvent we) {
|
||||
Window self = we.getWindow();
|
||||
Window owner = self.getOwner();
|
||||
if (owner != null) {
|
||||
owner.dispose();
|
||||
} else {
|
||||
self.dispose();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
switch (cmd) {
|
||||
case 0:
|
||||
dlg.setAlwaysOnTop(true);
|
||||
dlg.setVisible(true);
|
||||
break;
|
||||
case 1:
|
||||
(new Thread(new TopmostMaker(dlg))).start();
|
||||
dlg.setVisible(true);
|
||||
break;
|
||||
case 2:
|
||||
dlg.setFocusableWindowState(false);
|
||||
(new Thread(new TopmostMaker(dlg))).start();
|
||||
dlg.setVisible(true);
|
||||
break;
|
||||
default:
|
||||
PassFailJFrame.log("Unsupported operation :(");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class TopmostMaker implements Runnable {
|
||||
final Window wnd;
|
||||
|
||||
public TopmostMaker(Window wnd) {
|
||||
this.wnd = wnd;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
PassFailJFrame.log("Let's wait");
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (InterruptedException ie) {
|
||||
PassFailJFrame.log("Test was interrupted. " + ie);
|
||||
ie.printStackTrace();
|
||||
}
|
||||
PassFailJFrame.log("Let's make it topmost");
|
||||
wnd.setAlwaysOnTop(true);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user