import import import import

javax.swing.*; java.awt.*; javax.imageio.*;*;

//panel used to draw image on public class ImagePanel extends JPanel { //path of image private String path; //image object private Image img; public ImagePanel(String path) { //save path this.path = path; throws IOException

//load image img = File(path)); } //override paint method of panel public void paint(Graphics g) { //draw the image if( img != null) g.drawImage(img,0,0, this); } } //example of using image panel

Sign up to vote on this title
UsefulNot useful