• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Display Image in an Applet

 
Rohan Pujari
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


WHEN I LOAD THE APPLET THE IMAGE IS NOT DISPLAYED BUT THE MOMENT I RESIZE THE APPLET THE IMAGE IS DISPLAYED WHY IS THIS SO?
 
Craig Wood
Ranch Hand
Pie
Posts: 1535
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Because the getImage method creates an instance of Image but does not actually load the image data into the jvm. You cannot draw the image if there is no data to draw. To load the data when using Toolkit methods use a MediaTracker. See the MediaTracker class api comments section for example code that shows how to do this. If you are using java version 1.4 or later you can use the ImageIO class to load images. It is easier. The Swing FAQ has an example.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic