원본글 주소 : 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;
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);
}
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);
}
});
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) {}
});
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);
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);
}
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
}
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
}
'소스기록장 > java' 카테고리의 다른 글
자바로 만든 리듬게임 - Rhythm and Beat(bms구동기) (19) | 2012.02.25 |
---|---|
[펌] 자바 성능 시간, 메모리 테스트 (0) | 2011.11.14 |
간단한 계산기 소스 (2) | 2011.06.12 |