An Image in an Applet
Previous    Next    Home    Source    Package

  1. The applet displays an image taken from a file named board.jpg on This is effortless in Java due to the URL class. So, to bring in the image we use something like
      Image board;
      String board_jpg = 
      try {
         board = (Toolkit.getDefaultToolkit()).getImage(new URL(board_jpg));
      } catch (MalformedURLException e) { }
    and to use it we can write
       g.drawImage(bgimage, 0, 0, this);