Jump to content

java code can't find problem

- - - - -

  • Please log in to reply
1 reply to this topic

#1
Extorzone admin

Extorzone admin

    Newbie

  • Members
  • Pip
  • 4 posts
i have set up a java applet for my firefox browser im a beginner at java and im using a book called "sams teach yourself java 6 in 24 hours" and i made this applet and added it to index.html and it won't show up in firefox i used netbeans to make it and compiled it with cmd


import java.awt.*;


public class applet1 extends javax.swing.JApplet {

    String h1 = getParameter("headline1");

    String h2 = getParameter("headline2");

    String h3 = getParameter("headline3");


    @Override

    public void init() {


    }

    @Override

    public void paint(Graphics screen) {

        Graphics2D screen2D = (Graphics2D) screen;

        screen2D.drawString(h1, 20, 30);

        screen2D.drawString(h2, 20, 30);

        screen2D.drawString(h3, 20, 30);

    }

}



and the html file it's uploaded in:


<html>

<title>

</title>

<head>

</head>

<body>


<applet code="java.class" codebase="src" height="100" width="200">



<param name="headline1" value="marcus eat vegard">

<param name="headline2" value="but">

<param name="headline3" value="vegard makes marcus puke him up again">



</applet>


</body>

</html>


+rep for answering what so ever :)

Edited by Roger, 14 May 2011 - 08:59 PM.


#2
wim DC

wim DC

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,084 posts
  • Programming Language:Java, JavaScript, PL/SQL
  • Learning:Java

String h1 = getParameter("headline1");

String h2 = getParameter("headline2");

String h3 = getParameter("headline3");

Happens too early, put the getParameters in the init method instead.

If it still doesn't work, try adding the archive parameter to your applet tag

<applet ... .... archive="applet1.jar" ... >

...

</applet>


Not sure about firefox, but chrome is being annoying with applets if you have more than 1 JRE installed.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users