Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Screen Class
- 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);
- }
- }
- //Main Class
- import java.awt.*;
- import javax.swing.JFrame;
- public class Java extends JFrame {
- public static void main(String args[]){
- DisplayMode dm = new DisplayMode(800,600,16,DisplayMode.REFRESH_RATE_UNKNOWN);
- Java j = new Java();
- j.run(dm);
- }
- public void run(DisplayMode dm){
- setBackground(Color.black);
- setForeground(Color.white);
- setFont(new Font("Arial", Font.PLAIN, 24));
- Screen s = new Screen();
- try{
- s.setFullScreen(dm, this);
- try{
- Thread.sleep(5000);
- }catch(Exception ex){}
- }finally{
- s.restoreScreen();
- }
- }
- public void paint(Graphics g){
- g.drawString("This is gonna be awesome!", 200, 200);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement