Created
June 29, 2012 19:26
-
-
Save Jimshii/3020101 to your computer and use it in GitHub Desktop.
Screen class
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
package package_full; | |
import java.awt.*; | |
import javax.swing.JFrame; | |
public class Screen { | |
private GraphicsDevice vc; | |
public Screen(){ | |
GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment(); | |
vc = env.getDefaultScreenDevice(); | |
} | |
public void setFullScreen(DisplayMode dm, JFrame window) { | |
window.setUndecorated(true); | |
window.setResizable(false); | |
vc.setFullScreenWindow(window); | |
if(dm != null && vc.isDisplayChangeSupported()) { | |
try{ | |
vc.setDisplayMode(dm); | |
}catch(Exception ex) {} | |
} | |
} | |
public Window getFullScreenWindow() { | |
return vc.getFullScreenWindow(); | |
} | |
public void restoreScreen() { | |
Window w = vc.getFullScreenWindow(); | |
if(w != null) { | |
w.dispose(); | |
} | |
vc.setFullScreenWindow(null); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment