Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me.Kenny.GUI_WINDOW_INITILIZATION;
- public static void main(String[] args){
- DisplayMode dm = new DisplayMode(1200,800,32, DisplayMode.REFRESH_RATE_UNKNOWN);
- Main m = new Main();
- m.run(dm);
- }
- public void run(DisplayMode dm1){
- setBackground(Color.PINK);
- setForeground(Color.WHITE);
- setFont(new Font("Arial", Font.PLAIN, 24));
- Screen s = new Screen();
- try{
- s.setFullScreen(dm1, this);
- try{
- Thread.sleep(5000);
- }catch(Exception e){}
- }finally{
- s.restoreScreen();
- }
- }
- public void paint(Graphics g){
- g.drawString("This is gonna be awesome", 300, 300);
- }
- package me.Kenny.GUI_WINDOW_INITILIZATION;
- 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);
- System.out.println("is in try");
- }catch(IllegalArgumentException ex){
- System.out.println("Unable to set Display mode");
- }
- }
- }
- public Window getFullScreenWindow(){
- return vc.getFullScreenWindow();
- }
- public void restoreScreen(){
- Window w = vc.getFullScreenWindow();
- if (w != null){
- w.dispose();
- }
- vc.setFullScreenWindow(null); //closes window
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement