2008년 8월 9일 토요일

java 버튼 만들었는데 보이지가 않아요




import java.awt.*;
import java.awt.event.*;

import javax.swing.JFrame;

public class A01 extends JFrame implements WindowListener
{

public static void main(String[] args)//창생성
{
A01 f = new A01();

f.setSize(300,300);
f.setVisible(true);


}

//버튼
Button btn1, btn2, btn3;
public void init()
{

btn1 = new Button("버튼1");
btn1.setBounds(10,10,100,20);
add(btn1);


}

public A01()//캠버스 생성
{
//여기에 init()를 추가하세요
//의문점 쪽지주세요
init();
MyCanvas mc = new MyCanvas();
add("Center", mc);
addWindowListener(this);

}

/*class paint2
{
MyCanvas2 mc2 = new MyCanvas2();
add("Center", mc2);
}

class MyCanvas2 extends Canvas//이미지출력캔버스
{
public void paint(Graphics g)
{
Toolkit myToolkit2 = Toolkit.getDefaultToolkit();
Image myImage = myToolkit2.getImage("c:kaka.jpg");
g.drawImage(myImage , 0, 0, this);

}
}*/

class MyCanvas extends Canvas//이미지출력캔버스
{
public void paint(Graphics g)
{
Toolkit myToolkit = Toolkit.getDefaultToolkit();
Image myImage = myToolkit.getImage("c:/android.jpg");
g.drawImage(myImage , 0, 0,300,300, 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