원본글 주소 : http://proneer.tistory.com/trackback/244
import java.awt.Graphics;
import java.awt.GraphicsEnvironment;
import java.awt.Image;
import java.awt.Frame;
import java.awt.Toolkit;
import java.awt.MediaTracker;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.net.MalformedURLException;
import java.net.URL;
public class FullModeViewer extends Frame {

     private Image image;
 
     // Class constructor 
     public FullModeViewer(String source) throws MalformedURLException {
          // loading image
          if (source.startsWith("http://"))   // http:// URL was specified
               image = Toolkit.getDefaultToolkit().getImage(new URL(source));
          else
               image = Toolkit.getDefaultToolkit().getImage(source); // otherwise - file

          MediaTracker mediaTracker = new MediaTracker(this);
          mediaTracker.addImage(image, 0);
          try {
               mediaTracker.waitForID(0);
          } catch (InterruptedException ie) {
               System.err.println(ie);
               System.exit(1);
          }
          // Exiting program on window close
          addWindowListener(new WindowAdapter() {
               public void windowClosing(WindowEvent e) {
                    System.exit(0);
          }
          });
          // Exitig program on mouse click
          addMouseListener(new MouseListener() {
               public void mouseClicked(MouseEvent e) { System.exit(0); }
               public void mousePressed(MouseEvent e) {}
               public void mouseReleased(MouseEvent e) {}
               public void mouseEntered(MouseEvent e) {}
               public void mouseExited(MouseEvent e) {}
          });
          // remove window frame
          this.setUndecorated(true);
 
          // window should be visible
          this.setVisible(true);
          // switching to fullscreen mode
          GraphicsEnvironment.getLocalGraphicsEnvironment().
          getDefaultScreenDevice().setFullScreenWindow(this);
     }
 
     public void paint (Graphics g) {
          if (image != null)                              // if screenImage is not null (image loaded and ready)
               g.drawImage(image, 0, 0, null);
      }
     // Program entry
     public static void main(String[] args) throws Exception {
          if (args.length < 1)                         // by default program will load AnyExample logo
               new FullModeViewer(http://image_path);
          else
               new FullModeViewer(args[0]);  // or first command-line argument
      }

+ Recent posts