Skip to content

Instantly share code, notes, and snippets.

@fahadsiddiqui
Created March 15, 2017 12:32
Show Gist options
  • Save fahadsiddiqui/4b6a5d01d1b00b43279dc27730eb6fea to your computer and use it in GitHub Desktop.
Save fahadsiddiqui/4b6a5d01d1b00b43279dc27730eb6fea to your computer and use it in GitHub Desktop.
public final class ScreenSaver {
public static final void main(final String[] args) throws Exception {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
final JFrame screenSaverFrame = new JFrame();
screenSaverFrame.setDefaultCloseOperation(
WindowConstants.EXIT_ON_CLOSE);
screenSaverFrame.setUndecorated(true);
screenSaverFrame.setResizable(false);
screenSaverFrame.add(new JLabel("This is a Java Screensaver!",
SwingConstants.CENTER), BorderLayout.CENTER);
screenSaverFrame.validate();
GraphicsEnvironment.getLocalGraphicsEnvironment()
.getDefaultScreenDevice()
.setFullScreenWindow(screenSaverFrame);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment