Search code examples
javaswingscreensaverminimize

Fullscreen java app minimizes when screensaver turns on


I have an app that sets a fullscreen frame but seems to minimize when the screensaver turns on. I want this app to be the only application that the users of the touchscreen kiosks can use so this is a problem. Is there anyway to prevent this?


Solution

  • Another way is to add a window listener and reset state when it's deactivated:

            frame.addWindowListener(new WindowAdapter() {
                @Override
                public void windowDeactivated(WindowEvent e) {
                    frame.setExtendedState(JFrame.MAXIMIZED_BOTH);
                    // or go to fullscreen mode here
                }
            });
    

    But disabling screensaver might be the best thing to start with.