Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Applet to view images

813128Jun 23 2011 — edited Jun 27 2011
Hi,

I wan't to develop an applet to view tiff images and maybe pdfs.
I did the following and is not working:
import java.applet.*;
import java.awt.*;
import java.net.*;
public class Main extends Applet
{
  private Image image;
  private AppletContext context;
  public void init()
  {
      context = this.getAppletContext();
      
        String imageURL = "image.tif";
      
      try
      {
         URL url = new URL(this.getDocumentBase(), imageURL);
         image = context.getImage(url);
      }catch(MalformedURLException e)
      {
         e.printStackTrace();
         // Display in browser status bar
         context.showStatus("Could not load image!");
      }
   }
   public void paint(Graphics g)
   {
      context.showStatus("Displaying image");
      g.drawImage(image, 0, 0, 200, 84, null);
   }
}
Any ideas of why is not working?

Thanks in advance

Edited by: 810125 on 23-jun-2011 4:42
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 25 2011
Added on Jun 23 2011
12 comments
251 views