Re: How to create an Applet as a file.class ?

Javascript

How to create an Applet as a file.class ?


judy 08-02-2006, 8:27 PM

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

 

Re: How to create an Applet as a file.class ?


cato 06-10-2008, 6:48 PM
Dear judy,did you put your class file and your htm file in the same directory?

Re: How to create an Applet as a file.class ?


treydx 06-14-2008, 8:11 AM
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...

Re: How to create an Applet as a file.class ?


Bleiddynn 10-17-2008, 8:55 AM
In Java you do NOT write the code in a class file. You must write the code in a test.java file then COMPILE it into a test.class file which is a binary file. If you make changes to the java file you must re-compile and re-upload the newly created class in order to see the changes.

Re: How to create an Applet as a file.class ?


hits 12-05-2008, 6:31 AM
 Bleiddynn wrote:
In Java you do NOT write the code in a class file. You must write the code in a test.java file then COMPILE it into a test.class file which is a binary file. If you make changes to the java file you must re-compile and re-upload the newly created class in order to see the changes.



Hi,,, i am hitesh..

i have to problems

1) i am using a java applet in dot net nuke... my applet is working ..but when ever i am applet is fire so...its clear my all sessions values.

2) you have talk that.. I have upload.java + upload.class files. so ., how can i call this file in my aspx page... please give me some suggestion... i need really help....please
webhost4life.com

Powered by Community Server, by Telligent Systems