Domanda

I've got a Java applet that will only work correctly one time on any browser. I've run through the java console and cleared the class cache, refreshed the page, reloaded the browser, emptied the browser cache and I can only get this applet to work once. I've tried chrome, IE10 and FireFox. any help is greatly appreciated.

here is the applet code:

import java.applet.*;
import java.awt.*;

public class SolarSystemV3 extends Applet{

int input;

public void init()
{

    String webInput = getParameter("mer");
    if(webInput != null)
        input = Integer.parseInt(webInput);

}

public void paint(Graphics g)
{

    if(input == 1)
    {
        g.drawString("hello mercury", 25, 25);
    }

}


}

here is the HTML:

<body>
<article>
<img src="mercury.jpg" alt="Mercury"/>
<h1>Mercury</h1>
<applet code = "SolarSystemV3.class" width="320" height="120" 
<param = "mer" value = "1"/>
</applet>
</article>
</body>
</html>
È stato utile?

Soluzione 2

The problem is here in your HTML. name attribute of param tag is missing.

<param = "mer" value = "1"/>

use

<param name = "mer" value = "1"/>

The parameter mer is not properly defined in HTML.

For more info have a look at Defining and Using Applet Parameters

Altri suggerimenti

..here is the HTML:

No it's not. I don't mean it is not there, I mean what's there is not HTML. It is some rubbish hacked out by a programmer that is pretending to be HTML. There are at least 3 errors in it.

To find out what the errors are, use an HTML validation service.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top