Omnimaga
General Discussion => Technology and Development => Computer Programming => Topic started by: Snake X on March 08, 2011, 09:19:45 pm
-
??? has anyone ever set up a java applet successfully before? I need help. I have my html file for the applet hosted here: http://greyshadowencodes.webs.com/car.html
and I HAVE the applet (IT IS a .class file, trust me it is I know it has to be .class and compiled which it is) in the same root directory as the car.html file (the page where the applet should be running) and it gives me an error which I don't get. Can anyone help me?
I'll even upload my .java file and you can view source of my link i posted if you need to.
-
Try this
<applet
codebase = "."
code = "car.class"
name = "Car"
width = "600"
height = "600"
hspace = "0"
vspace = "0"
align = "middle"
>
</applet>
-
:( no that didn't work either. umm ill try lowercase 'car' under name
edit: :( still didn't work. you can just refresh the page if you wanna see
edit edit: I am working in a webs account if that helps
-
It's not your html at all. You need to read up more on how to do applets. I suggest you look at this (http://download.oracle.com/javase/tutorial/deployment/applet/index.html). I also like compiling into .jar even if it is one class. It keeps things all neat and tidy to me. Add this to your code: (It's just another method like paint. It initializes the app. It also might be good to call super.paint(g) just in case the super class needs to paint something. This is because the paint method goes all the way back to java.awt.Container. It is explained fairly well here (http://download.oracle.com/javase/1.4.2/docs/api/java/awt/Container.html#paint(java.awt.Graphics)).
public void init() {
super.init();
}
-
<p align="center">
<applet code="MainClass.class" width="640" height="640" alt="Applet GUIDemo demonstrates some basic GUI components">
<div align="center">
<p>
<b>Java is not enabled in your browser</b>
</applet></p>
1. I know this code is XHTML wrong, but I don't use XHTML;
2. The problem is probably the class file;
3. This works great for me (with functional applets classes) so try it too.