0

I have developed a small JApplet for a site. It's the first time I do such a thing, so it's probably a stupid error or misundestanding, but I can't find out what it is.

Here is the first class called from the HTML:

public class MapGenerator extends JApplet {

    private static final long serialVersionUID = 1L;
    private int numero_immagini;
    private BufferedImage[] images;
    private int[] floors;

    private static final String N_IMMAGINI = "numero_immagini";
    private static final String IMMAGINE = "immagine";
    private static final String PIANO_IMMAGINE ="numero_piano";


    public void init() {

        numero_immagini = Integer.parseInt(this.getParameter(N_IMMAGINI));

        images = new BufferedImage[numero_immagini];
        floors = new int[numero_immagini];

            for(int i=0; i< numero_immagini; i++) {
                try {
                    URL url = new URL(this.getParameter(IMMAGINE+i));
                    images[i] = ImageIO.read(url);
                    floors[i] = Integer.parseInt(this.getParameter(PIANO_IMMAGINE+i));
                } catch (IOException ioe) {}
            }    
    }

    public void start() {

        Editor ed = new Editor(this.getContentPane(), images, floors);

        this.setSize(400, 400);

        this.add(ed.getPanel());

        Toolkit kit = this.getToolkit();
        Dimension dim = kit.getScreenSize();
        this.setBounds(dim.width/4, dim.height/4, dim.width/4, dim.height/4);
        this.setVisible(true);
        this.repaint();
    }
}

And here is the HTML:

<applet code="MapGenerator.class"
    archive="MapGenerator.jar"
    width= 400 height = 200>

        <param name=numero_immagini value=1>
        <param name=immagine0 value="IMG_20111009_171138.jpg">
        <param name=numero_piano0 value=0>
</applet>

In Eclipse I haven't any problem at all, but when I tried with Chrome the page show only a gray box.

Thank to all for help.

EDIT

The app cannot load images from the link that I pass.

It trows, testing with a random link image

java.security.AccessControlException: access denied (java.net.SocketPermission www.hyros.net:80 connect,resolve)
java.lang.NullPointerException
Marco Fedele
  • 2,090
  • 2
  • 25
  • 45

1 Answers1

0

The problem is the code, and not the way I use HTML, the jar file or other things, so I opened a new question here, to describe the problem in a more correct way.

Thank you for your answers.

Community
  • 1
  • 1
Marco Fedele
  • 2,090
  • 2
  • 25
  • 45