Results 1 to 2 of 2
  1. #1
    adamsives's Avatar
    adamsives is offline Member
    Join Date
    Apr 2009
    Posts
    2
    Rep Power
    0

    Default Help with viewing Applet

    I'm new to programming and REALLY new to JAVA. I'm trying to get teh following to work and am not having too much luck...

    I'm getting the instructions from a webpage Sams Teach Yourself Java 2 in 24 Hours

    Steps I’m taking
    1. I save the following code to a text file named “RootApplet.java”

    import java.awt.*;

    public class RootApplet extends javax.swing.JApplet {
    int number;

    public void init() {
    number = 225;
    }

    public void paint(Graphics screen) {
    Graphics2D screen2D = (Graphics2D) screen;
    screen2D.drawString("The square root of " +
    number +
    " is " +
    Math.sqrt(number), 5, 50);
    }
    }

    2. open a command prompt and compile it with command javac RootApplet.java

    3. open a new Word doc and paste the following code into it, save as an HTML

    <applet code="RootApplet.class" height=100 width=300>
    </applet>

    4. open a command prompt and type “RootApplet.html” and the following displays.

    <applet code="RootApplet.class" height=100 width=300>
    </applet>

    I was expecting to see was an HTML page with

    "The square root of 225 is 15.0"

    on it...

    Can someone tell me what is wrong here?

  2. #2
    adamsives's Avatar
    adamsives is offline Member
    Join Date
    Apr 2009
    Posts
    2
    Rep Power
    0

    Default Fixed!

    FIXED!

    To resolve, I copied the text

    "<applet code="RootApplet.class" height=100 width=300>

    </applet>"

    on to a Notepad document and saved as "RootApplet.html" and it worked first go.

Similar Threads

  1. viewing sourcecode
    By wildheart in forum Advanced Java
    Replies: 12
    Last Post: 04-04-2009, 05:44 AM
  2. Viewing contents of zip file
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 03-03-2008, 06:16 PM
  3. Viewing contents of JAR file
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 12-21-2007, 04:12 PM
  4. Viewing a user's periphials from an applet
    By jason2li in forum Java Applets
    Replies: 0
    Last Post: 08-07-2007, 03:51 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •