-2
public class Test extends JApplet {
    public void init () {
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                createGUI();
            }
        });
    }

    public void createGUI() {
        getContentPane().add(new GUIThing());
    }
}

public class GUIThing extends JPanel {
    BufferedImage image;
    public GUIThing() {
    try {
        image=ImageIO.read(new File("gladiator.gif"));
    } catch (IOException e) {
        e.printStackTrace();
    }
    }
    public void paintComponent(Graphics g) {
        g.drawString("WTF", 20, 20);
        g.drawImage(image,100,100,100, 100, null);
    }
}



<applet code="test.Test"
        archive="test.jar"
        width = 1000,
        height = 1000 >

gladiator.gif is put in the same directory as the HTML file, yet it dont get drawn.

ive tried not including gladiator.gif, and instead of writing the string Couldnt!!! it shows a blank white page...

this is the gladiator if any1 wants to give it a shot: this is the gladiator if any1 wants to give it a shot

When i delete the drawImage related lines it does show the WT string, so i guess its just something weird with the image drawing, what could it be?

Ofek Ron
  • 8,354
  • 13
  • 55
  • 103

1 Answers1

1

A typical (untrusted) applet cannot create File objects, as your Java Console would report. Form an URL to the image, and use that instead.

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433