My Java Swing application window disappears whenever I drag it with the mouse from one monitor to another. It is visible while I drag it, but it disappears immediately when I release the mouse button. I would rather that the window didn't disappear. Why does it disappear?
When I activate Mission Control, the Swing Window appears at the bottom of the desktop where I dragged it. Deactivating Mission Control causes it to slide off the bottom of the screen.
It doesn't matter which Java Swing application I run. For those who want the code, here's a simple Java Swing application that exhibits the behavior I'm describing, enjoy:
import java.awt.*;
import javax.swing.*;
class SimpleSwing {
public static void main(final String... args) {
SwingUtilities.invokeLater(new Runnable() {
@Override public void run() {
JFrame frame = new JFrame();
JPanel contentPane = new JPanel();
contentPane.add(new JLabel("Hello World!"));
frame.setContentPane(contentPane);
frame.pack();
frame.setVisible(true);
}
});
}
}
My environment is Oracle Java JDK (latest as of this writing) on Mac OS X Yosemite (latest as of this writing):
java version "1.8.0_40"
Java(TM) SE Runtime Environment (build 1.8.0_40-b27)
Java HotSpot(TM) 64-Bit Server VM (build 25.40-b25, mixed mode)
OS X Yosemite Version 10.10.2 (14C1510)
Darwin Kernel Version 14.1.0
I want to know how to stop OS/X from putting an application off screen in the first place. Very annoying when you are working and concentrating and the screen just disappears from view. Robsays July 10, 2019 at 7:37 am Hold down ctrl and alt, grab bottom corner of after effects window and drag. Top of window should drop down.
macOS: Bring Off-Screen Window Back Onto Screen By Mitch Bartlett29 Comments You have the application open, but you can’t see the window for it in macOS? Try these tips. Fix 1 – Zoom Select the application in the dock, then choose “Window” > “Zoom“. Fix 2 – Resolution Select the Apple Menu, then choose “System Preferences…” > “Displays“.
Select the application in the dock, then choose “Window” > “Zoom“. Fix 2 – Resolution Select the Apple Menu, then choose “System Preferences…” > “Displays“. Ensure “Scaled” is selected under “Resolution“. Choose any other setting. This should force the window for the application back on the screen where you can drag it to a safe place.
Try selecting “Apple” Menu, then “Force Quit… From there, select the application, then “Force Quit“. This should allow you to start the application new, and hopefully where it’s back on the screen. Hopefully, one of the above fixes worked for you.
Step: Before frame.setVisible(true); you can add below two line of code and then test again.
frame.setLocation(500, 500); frame.setAlwaysOnTop(true);
Try the following:
Hope this helps, but I'm not sure if it is the solution.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With