• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Problem using JApplets with normal Java classes

 
Ranch Hand
Posts: 750
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic