Friday, 10 February 2012

Java-Full Screen App

burkan.java


import java.awt.*;
import javax.swing.JFrame;
public class burkan extends JFrame{

 /**
  * @param args
  */
public static void main(String[] args) {
 // TODO Auto-generated method stub
 DisplayMode dm = new DisplayMode(800,600,16,DisplayMode.REFRESH_RATE_UNKNOWN);
 burkan b = new burkan();
 b.run(dm);
}

public void run(DisplayMode dm){
    setBackground(Color.WHITE);
    setForeground(Color.BLACK);
    setFont(new Font("Arial",Font.PLAIN,24));
  
    FullScreen s = new  FullScreen();
    try{
    s.setFullScreen(dm, this);
    try{
  
    Thread.sleep(3000);
   
    }catch(Exception ex){}
    }finally{
    s.restoreScreen();
    }
}
 
public void paint(Graphics g){
 if(g instanceof Graphics2D){
  Graphics2D g2 = (Graphics2D)g;
  g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
 }
  g.drawString("Hello World!!!", 200, 200);
 } 
}

FullScreen.java

import javax.swing.JFrame;
import java.awt.*;
public class FullScreen {
 private GraphicsDevice vc;
 
 public FullScreen(){
  
  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);
 }
  
}

1 comment:

  1. Thanks for your Quality information the product developed by the company is perfect. Thanks for giving such a wonderful blog....................Please contact us for Oracle Fusion Financials Training details in our Erptree Training Institute

    ReplyDelete