CODING:
import javax.swing.*;import java.awt.*;
public class img extends Canvas {
public void paint(Graphics g)
{
Toolkit t = Toolkit.getDefaultToolkit();
Image i = t.getImage("pic.png");
g.drawImage(i,100,50,this);
}
public static void main(String args[]){
JFrame myFrame = new JFrame("This is my frame");
myFrame.setSize(500,400);
myFrame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
myFrame.setVisible(true);
img m = new img();
myFrame.add(m);
}
}
0 comments:
Post a Comment