import java.awt.Choice;
import java.awt.FlowLayout;
import java.awt.Frame;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Label;
import java.awt.Toolkit;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
public class WindowTest extends Frame implements WindowListener {
Image img = null;
Image pngImg = null;
public WindowTest() {
setLayout(null);
Toolkit tk = Toolkit.getDefaultToolkit();
img = tk.getImage("house.jpg");
// img = tk.getImage("c:\\tmp\\pig.png");
// img = tk.getImage("\\\\192.168.3.3\\공유\\경치.gif");
pngImg = tk.getImage("bird.png");
//this.getWitdh 현재 폭을 얻어온다.
img.getWidth(this);
img.getHeight(this);
setSize(640,480);
// setLocation(100, 0);
setVisible(true);
addWindowListener(this);
}
@Override
public void paint(Graphics g) {
// TODO Auto-generated method stub
super.paint(g);
int imgWidth = img.getWidth(this);
int imgHeight = img.getHeight(this);
g.drawImage(img, 0, 0, this);
g.drawImage(pngImg, 200, 200, this);
setSize(imgWidth, imgHeight);
System.out.println(imgWidth + " " + imgHeight);
}
@Override
public void windowActivated(WindowEvent arg0) {
// TODO Auto-generated method stub
}
@Override
public void windowClosed(WindowEvent arg0) {
// TODO Auto-generated method stub
}
@Override
public void windowClosing(WindowEvent arg0) {
// TODO Auto-generated method stub
System.exit(0);
}
@Override
public void windowDeactivated(WindowEvent arg0) {
// TODO Auto-generated method stub
}
@Override
public void windowDeiconified(WindowEvent arg0) {
// TODO Auto-generated method stub
}
@Override
public void windowIconified(WindowEvent arg0) {
// TODO Auto-generated method stub
}
@Override
public void windowOpened(WindowEvent arg0) {
// TODO Auto-generated method stub
}
}