Guest User

Untitled

a guest
May 24th, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. import java.awt.*;
  2. import java.awt.event.*;
  3. import javax.swing.JFrame;
  4.  
  5. public class FullScreenFrame extends JFrame implements KeyListener {
  6.  
  7. public FullScreenFrame () {
  8. addKeyListener(this);
  9. setUndecorated(true);
  10. GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
  11.  
  12. if (gd.isFullScreenSupported()) {
  13. try {
  14. gd.setFullScreenWindow(this);
  15. }
  16. finally {
  17. gd.setFullScreenWindow(null);
  18. }
  19. }
  20. else {
  21. System.err.println("Full screen not supported");
  22. }
  23.  
  24. setVisible(true);
  25. }
  26.  
  27. public void keyTyped(KeyEvent e) {}
  28. public void keyPressed(KeyEvent e) {}
  29. public void keyReleased(KeyEvent e) {
  30. setVisible(false);
  31. dispose();
  32. }
  33.  
  34. public static void main (String [] args) {
  35. new FullScreenFrame();
  36. }
  37. }
  38.  
  39. try {
  40. gd.setFullScreenWindow(this);
  41. }
  42. finally {
  43. gd.setFullScreenWindow(null);
  44. }
  45.  
  46. public FullScreenFrame() {
  47. addKeyListener(this);
  48.  
  49. GraphicsDevice gd =
  50. GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
  51.  
  52. if (gd.isFullScreenSupported()) {
  53. setUndecorated(true);
  54. gd.setFullScreenWindow(this);
  55. } else {
  56. System.err.println("Full screen not supported");
  57. setSize(100, 100); // just something to let you see the window
  58. setVisible(true);
  59. }
  60. }
Add Comment
Please, Sign In to add comment