Adilol

Screen.java

Nov 12th, 2011
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.76 KB | None | 0 0
  1. package core;
  2. import java.awt.*;
  3. import javax.swing.JFrame;
  4.  
  5. public class Screen {
  6.     private GraphicsDevice vc;
  7.  
  8.     public Screen(){
  9.         GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
  10.         vc = env.getDefaultScreenDevice();
  11.     }
  12.    
  13.     public void setScreenSize(DisplayMode dm, JFrame window) {
  14.         window.setUndecorated(false);
  15.         window.setResizable(false);
  16.         window.setSize(800, 600);
  17.        
  18.         if (dm !=null && vc.isDisplayChangeSupported()){
  19.             try{
  20.                 vc.setDisplayMode(dm);
  21.                
  22.             }catch(Exception ex){
  23.             }
  24.         }
  25.     }
  26.     public Window getWindow(){
  27.         return vc.getFullScreenWindow();
  28.     }
  29.     public void RestoreScreen(){
  30.         Window w = vc.getFullScreenWindow();
  31.         if(w != null){
  32.             w.dispose();
  33.         }
  34.         vc.setFullScreenWindow(null);
  35.     }
  36. }
  37.  
  38.  
Advertisement
Add Comment
Please, Sign In to add comment