aspose file tools*
The moose likes Applets and the fly likes Problem using JApplets with normal Java classes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Applets
Bookmark "Problem using JApplets with normal Java classes" Watch "Problem using JApplets with normal Java classes" New topic
Author

Problem using JApplets with normal Java classes

colin shuker
Ranch Hand

Joined: Apr 11, 2005
Posts: 744
Hi, I'm making a pacman game using Netbeans 3.5.
I have a simple JApplet shown here:



And also a java class called PacmanGame.java, which extends JPanel, and overrides the paintComponent(Graphics g) method.

Now, I also have a java class called Sprite.java, which is used to draw the sprites.

When I execute PacmanApplet in Netbeans, everything is fine, and the sprites come up on screen. However if I try to invoke the applet using an HTML file (see below):


then the HTML page doesnt show anything but a gray square.
Then, if I remove the line of code from PacmanGame that uses the Sprite class it works again, but without the sprites.

I'm not sure whats going on here, all files are in the same directory (outside of WEB-INF)

Any help will be very much appreciated. Thanks
Lin Shen
Ranch Hand

Joined: Oct 08, 2003
Posts: 57
Could you try pack both classes into a jar file. And in your HTML file, try this:

<APPLET CODE=PacmanApplet.class
archive="YourJar.jar"
CODEBASE='.'
WIDTH=1100
HEIGHT=700>
</APPLET>
colin shuker
Ranch Hand

Joined: Apr 11, 2005
Posts: 744
Hi
Do you mean all 3 class files together in a JAR file?
I need to upload them into www.freewebs.com ro www.geocities.com
and I'm not sure if they can do this?
If I just uploaded the JAR file, I dont think the HTML file
would be able to call the class extending JApplet.
I'm not sure, I can try

Thanks
tito bayuadji
Greenhorn

Joined: Apr 18, 2002
Posts: 12
Perhaps there is an exception when loading the applet.
perhaps you can look the applet console, and see if there is an exception or not.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem using JApplets with normal Java classes