Results 1 to 2 of 2
Thread: Help with viewing Applet
- 04-09-2009, 02:56 AM #1
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?
- 04-09-2009, 07:28 AM #2
Similar Threads
-
viewing sourcecode
By wildheart in forum Advanced JavaReplies: 12Last Post: 04-04-2009, 04:44 AM -
Viewing contents of zip file
By Java Tip in forum Java TipReplies: 0Last Post: 03-03-2008, 05:16 PM -
Viewing contents of JAR file
By Java Tip in forum Java TipReplies: 0Last Post: 12-21-2007, 03:12 PM -
Viewing a user's periphials from an applet
By jason2li in forum Java AppletsReplies: 0Last Post: 08-07-2007, 02:51 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks