View Single Post
  #12 (permalink)  
Old 04-26-2008, 01:29 AM
hardwired hardwired is online now
Senior Member
 
Join Date: Jul 2007
Posts: 1,146
hardwired is on a distinguished road
Code:
g.drawImage(ff.jpeg, 0, 0, this);
Note how the image was loaded in post #8: use ImageIO to read a file constructed from/with the image path. This will return a BufferedImage which you can pass to the drawImage method. You must load the image before you can draw it.
Code:
classs Pseudo extends JPanel } BufferedImage image; public Pseudo() { String pathToImage = "ff.jpg"; try { image = ImageIO.read(new File(pathToImage)); } catch(IOException e) { // recover } } protected void paintComponent(Graphics g) { super.paintComponent(g); g.drawImage(image, 0, 0, this); } }
Reply With Quote