Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Displaying pictures in Java

This topic is 6008 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Here's the partial code:

public class Mine extends Applet {
Image in;
public void init() {
//load image from applets directory through the URL

//put the image into mediatracker

MediaTracker t=new MediaTracker(this);
try {
catch (InterruptedException e) {
System.out.println("error "+e);

public void paint(Graphics g) {

The image can either be a 'gif' or a 'jpg'. You use MediaTracker to make sure the image has loaded before trying to display it. The paint() method will be called somewhat regularly and this is where you paint your image.

PS. You should check out The Java Tutorial. It is one of the most comprehensive tutorials I have ever seen and its free. I also includes this information that you are looking for. You can do it online, or you can download it and use it at your convenience. I would also recommend downloading the Java Platform docs. This will be a good reference, once you finish the tutorial.

Make it work.
Make it right.
Make it fast.

Edited by - CaptainJester on December 12, 2001 2:18:20 PM

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!