Click to See Complete Forum and Search --> : applet help


keko4201
01-06-2005, 08:24 PM
hey guys hows it goin, finished with school now, and on my own i am learning applets. um now this might be a stupid question , but this isnt working for me, not sure whats up. how do i save a java text as a class file. cause im using this code and in the utorial, they show the target using a class file, not a .java file. not sure if it make a difference or not, so i used the file that it saved as(.Java).

can someone help

/////////////////////////////////////////////////////////////////////
java file
/////////////////////////////////////////////////////////////////////

import java.applet.Applet;
import java.awt.Graphics;

public class HelloWorld extends Applet {
public void paint(Graphics g) {
g.drawString("Hello world!", 50, 25);
}
}




with this html





<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>New Page 1</title>
</head>

<body>
<applet code="file:///C:/Documents and Settings/Me/Desktop/Web/HTML Development/Java/Class'/test.java" WIDTH="150" HEIGHT="25">


</applet>
</body>

</html>

but htis does not work, just gives me a grey box wit the target directory. any suggestions?

ray326
01-06-2005, 11:53 PM
The code attribute has to point to compiled Java, either a class file or a jar or zip.

buntine
01-07-2005, 03:18 AM
Your file should be named in referance to the name of the class. So rename your file HelloWorld.java and then use HelloWorld.class in the code attribute in your HTML.

keko4201
01-07-2005, 02:21 PM
yea i know buntin, it was a mistake on my part for that, even if i do that, it dont work

buntine
01-07-2005, 07:24 PM
Read this to get an overview of how Java Applets are supposed to be laid out: http://java.sun.com/docs/books/tutorial/applet/overview/index.html

Regards.