|
import java.awt. *;
import java.awt.event. *;
import javax.swing. *;
public class Test extends Frame
{
public Test ()
{
addWindowListener (new WindowAdapter ()
{
public void windowClosing (WindowEvent e)
{
dispose ();
System.exit (0);
}
});
}
public static void main (String args [])
{
Test mainFrame = new Test ();
JPanel jpanel = new JPanel ();
Image img = mainFrame.getToolkit (). GetImage ("c:\\bag.png");
mainFrame.add (jpanel);
mainFrame.setSize (400, 400);
mainFrame.setTitle ("DrawImage");
mainFrame.setVisible (true);
Graphics g = jpanel.getGraphics ();
while (! g.drawImage (img, 100, 100, mainFrame));
System.out.println ("Start Drawing!");
}
} |
|