/**
* @(#)DisplayImage.java
*
*
* @author - Anant Mahale
* @version 1.00 2013/6/28
*/
import java.awt.*;
import java.awt.event.*;
class image extends Frame
{
Image img;
public image()
{
setTitle("Image");
setSize(300,300);
setLocation(100,100);
MediaTracker mt=new MediaTracker(this);
img = Toolkit.getDefaultToolkit().getImage("post.jpg");
mt.addImage(img,0);
addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent we)
{
System.exit(0);
}
});
}
public void paint(Graphics g)
{
if(img != null)
g.drawImage(img, 0, 0, this);
else
g.clearRect(0, 0, getSize().width, getSize().height);
}
}
class DisplayImage
{
public static void main(String []args)
{
new image().setVisible(true);
}
}
No comments:
Post a Comment