creating html file
Hi :WAVE:
I have created a html file to run my applet as follows:
<html>
<head><Title>Binary Search Tree</Title></head>
<body>
<Applet code=CopyBinaryTreeDisplay.class height=480 width=640>
</Applet>
</body>
</html>
Problem is, whenever I run this I only get the title and then a grey square, none of my GUI shows at all. I don't know where I am going wrong with this, if I run my CopyBinarySearchTreeDisplay.Java from within Eclipse IDE it shows perfectly in the applet viewer.
Can anyone help me out with this? Is it a setting on my PC, although other htmls which Eclipse generated for me work its just Eclipse no longer generates.
I also created my GUI via netbeans as a form and then had to convert it to an applet and copy the code to Eclipse - would this have any bearing on the problem?
Thanks very much.
[956 byte] By [
JavaSado] at [2007-11-11 6:28:49]

# 1 Re: creating html file
Is the class file in the same directory as the html page ? if so, have your applet code
a package directrive ?
sjalle at 2007-11-11 22:41:14 >

# 2 Re: creating html file
Hi
Thanks for the quick response.
Yeah, I created it in the same directory as the class file, which is C:\workspace\CopyofBinaryTreeSearch.
Not sure what your question means I've afraid? I don't know whar a package directive is, where would I look for this?
In the directory, if it helps, I have the following files listed:
.classpath
.project
CopyBinaryTreeAction.class and .java
CopyBinaryTreeDisplay.class and .java
CopyBinaryTreeDisplay.html
CopyTreeNode.class and .java
java.policy.applet
look forward to hearing from you again :)
# 3 Re: creating html file
Also include in this in the applet tag
CODEBASE = "."
If there is, say a first line in your code like:
package project;
Then your class file should be in the directory 'project' under the directory where
your html file is and the tags class spec should be
code = "project.SomeClass.class"
But first you should check if your class file is found, the status bar should indicate
that. If your applet bugs out during the initiation process, it will say something like
"applet xxxx not initiated' you can check that by bringing up the java console, in IE
thats: Tools -> Sun Java Console
sjalle at 2007-11-11 22:43:18 >

# 4 Re: creating html file
Hi
I have checked and my class has no project listed at the top.
When I run the html, it runs an applet and says done in the bottom left - so it looks as though it is working - although not picking up my clas file presumably, hence no display of buttons etc.. just a grey box?
Did you mean to go to Tools -> Sun Java Console from within Internet Explorer..? If so, I couldn't find this.
Thanks very much for your patience with me!
# 5 Re: creating html file
Oh ?, then you must in some way have removed/hidden it. Its the top bar in IE
with options; file, Edit, Favorites, Tools and Help.
Bring up the console, then enter your applet's URL.
To me this seems like a coding error of some sort.
Btw, does your applet implement the public void init() method ?
sjalle at 2007-11-11 22:45:27 >

# 6 Re: creating html file
Hi
Thank you for still trying to help with this...
Yes, I am implementing the init method:
public void init()
{
btd = new CopyBinaryTreeAction();
btd.generateTree(); // call generateTree method from BinaryTreeAction to setup tree ready for paint
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
createGUI();
}
Would it help if I e-mailed you my classes and html file?
# 7 Re: creating html file
Yes, or u could just zip and attatch to a post here
PS: I'm not quite sure about this one:
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
It doesn't lool like something a regular applet would be able to do...
sjalle at 2007-11-11 22:47:19 >

# 8 Re: creating html file
Hi
Might take that line out then...!
Have attached the zip file :D
# 9 Re: creating html file
I get this when i try to load it (is the Sun Java Console)
java.lang.ClassNotFoundException: CopyBinarySearchTreeDisplay.class
sjalle at 2007-11-11 22:49:30 >

# 10 Re: creating html file
I added a package directive on top of each java source file.
package dev-archive1;
This means that when compiled the class files are stored in folder "dev-archive1"
under your source dir.
check the test here:
http://home.no.net/sjalle/CopyBinaryTreeDisplay.html
I put the html in top directory and made a dev-archive1 directory under that for
the class files.
If you omit the package directive then just put the class files in same
folder as the html and leave out the dev1. prefix of the class file name in
the applet tag.
sjalle at 2007-11-11 22:50:25 >

# 11 Re: creating html file
Hi
I tried the link but it just shows the grey box in the applet - is that what you see when you go to the link?
# 12 Re: creating html file
Nope, I see green buttons on left and bottom, and a paint area in center-right.
Have you tried IE restarting & refresh IE ? You may be looking at the cache.
sjalle at 2007-11-11 22:52:27 >

# 13 Re: creating html file
still not happening..!
must be something on my computer?
I need to get the html to work at college as I want to check the size of the screen - to see if its OK for the pooled computers resolution.
If I take all the files I sent you to college and then run the html from there - in theory should this work? And then if not, I could try your suggestion on package setting?
Thanks very much for your patience and help with this!
# 14 Re: creating html file
If it doesn't work on your computer it must be that you have not set IE properly.
Click Tools->internet options and select the "advanced" tab. Search the list of
selections and select "Use Sun JRE", "Enable java Console" and "JIT compiler"
If that does not work then download and install the JRE from SUN
NOTE: Your class file name was wrong in your html
IF you try loading the URL i posted on one of your school's pcs it had better work :confused:
Good Luck :)
sjalle at 2007-11-11 22:54:33 >

# 15 Re: creating html file
Hi
I cannot thank you enough - you are fantastic!! ;)
I have downloaded JRE (I thought JRE was already installed, never mind).
Then changed the name of the class in the html file, because as you say I spelt it wrong(what an idiot!).
It now works with your link or my html file so I can now go and try it at college later.
Just need to get it to display my image and actually do something now ...
Thanks ever so much, really appreciate people like you helping me out