Created
March 15, 2017 12:32
-
-
Save fahadsiddiqui/4b6a5d01d1b00b43279dc27730eb6fea to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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