Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem using JApplets with normal Java classes

 
colin shuker
Ranch Hand
Posts: 750
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 750
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic