Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.*;
- import java.awt.event.*;
- import javax.swing.JFrame;
- public class FullScreenFrame extends JFrame implements KeyListener {
- public FullScreenFrame () {
- addKeyListener(this);
- setUndecorated(true);
- GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
- if (gd.isFullScreenSupported()) {
- try {
- gd.setFullScreenWindow(this);
- }
- finally {
- gd.setFullScreenWindow(null);
- }
- }
- else {
- System.err.println("Full screen not supported");
- }
- setVisible(true);
- }
- public void keyTyped(KeyEvent e) {}
- public void keyPressed(KeyEvent e) {}
- public void keyReleased(KeyEvent e) {
- setVisible(false);
- dispose();
- }
- public static void main (String [] args) {
- new FullScreenFrame();
- }
- }
- try {
- gd.setFullScreenWindow(this);
- }
- finally {
- gd.setFullScreenWindow(null);
- }
- public FullScreenFrame() {
- addKeyListener(this);
- GraphicsDevice gd =
- GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
- if (gd.isFullScreenSupported()) {
- setUndecorated(true);
- gd.setFullScreenWindow(this);
- } else {
- System.err.println("Full screen not supported");
- setSize(100, 100); // just something to let you see the window
- setVisible(true);
- }
- }
Add Comment
Please, Sign In to add comment