Welcome to Webhost4life Forum Sign in | Join | Faq

Javascript

Started by judy at 08-02-2006 8:27 PM. Topic has 2 replies.

Print Search
Sort Posts:    
   08-02-2006, 8:27 PM
judy is not online. Last active: 8/3/2006 11:05:11 AM judy

Top 500 Posts
Joined on 08-03-2006
Posts 1
How to create an Applet as a file.class ?
Reply Quote

Hi, I am a WH4L user

I am new for java.. please help and teach me

am I right that I use like this ?

import java.awt.*;
import java.awt.event.*;
import java.applet.Applet;

I use text note to write a test.class
---------example--------------test.class---------------------------------------------
import java.awt.*;
import java.awt.event.*;
import java.applet.Applet;
public class test extends Applet implements mouselistener
{
int x,y;
boolean clicked=false;
public void int()
{
this.addmouselistener(this);
}
public void mouseclicked(mouseevent e)
{
clicked=true;
x=e.getX();
y=e.getY();
update();
}
public void paint(graphics g)
{
if(clicked){
g.setcolor(color.pink);
g.filloval(x-20,y-20,40,40);
}
}
public void mouseentered(mouseevent e){}
public void mouseexited(mouseevent e){}
public void mousepressed(mouseevent e){}
public void mousereleased(mouseevent e){}
}
_________________________________________

-----my test.htm to run test.class-------
<applet
code="test.class"
width="204"
height="170"
</applet>
------------result I got------------
fail to load java applet

Please help me to fix my mistakes.
Thank you.

Best Regards,
Judy

 


   Report 
   06-10-2008, 6:48 PM
cato is not online. Last active: 6/12/2008 9:51:42 AM cato

Not Ranked
Joined on 06-11-2008
Posts 1
Smile [:)] Re: How to create an Applet as a file.class ?
Reply Quote
Dear judy,did you put your class file and your htm file in the same directory?

   Report 
   06-14-2008, 8:11 AM
treydx is not online. Last active: 6/14/2008 8:46:45 AM treydx

Top 500 Posts
Joined on 06-01-2008
Posts 2
Re: How to create an Applet as a file.class ?
Reply Quote
First of all, Java is extremely different from JavaScript, so that is probably why you aren't getting any responses.  Try a Java forum.

Next, did you really type all of that in "test.class"?  You've got to put your code in a file called "classname.java" and compile it into "classname.class".  You're going to have a bunch of jibberish in "test.class" and it shouldn't be readable.  It's been a while since I've done Java/Applets, so I'm assuming your code is copy/pasted from somewhere else and the syntax is correct...

   Report 
Webhost4life Fo... » General Discuss... » Javascript » Re: How to create an Applet as a file.class ?

Powered by Community Server, by Telligent Systems