3

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?

davidahines
  • 3,976
  • 16
  • 53
  • 87

3 Answers3

3

The internet says that the cross-platform way to achieve this is to schedule keyboard events with this code:

import java.awt.Robot;
public void disableScreenSaver() throws AWTException {
  Robot r = new Robot();
  r.waitForIdle();
  r.keyPress(KeyEvent.VK_CONTROL);
  r.keyRelease(KeyEvent.VK_CONTROL);
}

and to schedule it to run every couple of minutes (e.g. with thread.sleep();). This way the screen-saver will not show up.

I have no idea, though, about a non-hackish, cross-platform solution, and I would be very happy to see one from someone who knows it :)

Miki
  • 7,052
  • 2
  • 29
  • 39
1

Probably (haven't tried it !) you'll get your answer by combining the answers to these questions:

Calling Win32 API method from Java

Need to disable the screen saver / screen locking in Windows C#/.Net

Of course this works only in Windows that's why I asked you about your OS :)

Community
  • 1
  • 1
Serafeim
  • 14,962
  • 14
  • 91
  • 133
1

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.

Denis Tulskiy
  • 19,012
  • 6
  • 50
  • 68