Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Question about JApplets and JPanels

 
colin shuker
Ranch Hand
Posts: 750
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I've just created my JApplet(jap.java), which uses an inner-class(Drawer.java) that extends
JPanel to do the drawing part of applet.
In my IDE(netbeans 3.5) the applet works fine.

Annoyingly, when trying to upload the inner-class(Drawer.java) class file to Yahoo Geocities(web site creator), it won't upload, I think thats because of the $ in jap$Drawer.class

This is so frustrating, I doubt anyone knows how to do this, if its possible at all.
The other options I can think of are:
1. Keep the Drawer.java class as a separate class from jap.java, not sure if I can do this, I had problems when I just tried it.
2. Just use one class, the problem here is that to use the paintComponent
method, I need to extend JPanel class, but obviously I can't extend JApplet and JPanel at the same time. So I was wondering if it was possible to implement an interface in order to override paintComponent.

NB If you wondered why I'm not just extending Applet and using paint(), its because the screen keeps flashing when I call repaint().

Hope someone can shed some light on any part of this. Thanks
 
Rob Spoor
Sheriff
Posts: 20827
68
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could try using JAR files with your class files inside.
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!