2008년 8월 8일 금요일

자바 그림 불러오기




import java.awt.Canvas;
import java.awt.Frame;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Toolkit;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;

public class A01 extends Frame implements WindowListener
{
public static void main(String[] args)
{
A01 f = new A01();
f.setSize(600,400);
f.setVisible(true);
}

public A01()
{
MyCanvas mc = new MyCanvas();
add("Center", mc);

addWindowListener(this);
}

class MyCanvas extends Canvas//이미지출력캔버스
{
public void paint(Graphics g)
{
Toolkit myToolkit = Toolkit.getDefaultToolkit();
// 경로 지정하시면 됩니다. "c:/android.jpg" 이런식으로요.
//의문점 쪽지 주세여.
Image myImage = myToolkit.getImage("c:/android.jpg");
g.drawImage(myImage , 0, 0, this);

}
}

public void windowOpened(WindowEvent e) {}
public void windowClosing(WindowEvent e) {
System.exit(0);
}
public void windowClosed(WindowEvent e) {}
public void windowIconified(WindowEvent e) {}
public void windowDeiconified(WindowEvent e) {}
public void windowActivated(WindowEvent e) {}
public void windowDeactivated(WindowEvent e) {}

}

댓글 없음:

댓글 쓰기

-


Sidewinder


World


FishMusic


LaughingBaby