DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 15 of 16
  1. #1
    Join Date
    Jul 2005
    Posts
    32

    Question creating html file

    Hi

    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.

  2. #2
    Join Date
    Nov 2004
    Location
    Norway
    Posts
    1,560
    Is the class file in the same directory as the html page ? if so, have your applet code
    a package directrive ?
    eschew obfuscation

  3. #3
    Join Date
    Jul 2005
    Posts
    32
    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

  4. #4
    Join Date
    Nov 2004
    Location
    Norway
    Posts
    1,560
    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
    eschew obfuscation

  5. #5
    Join Date
    Jul 2005
    Posts
    32
    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!

  6. #6
    Join Date
    Nov 2004
    Location
    Norway
    Posts
    1,560
    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 ?
    eschew obfuscation

  7. #7
    Join Date
    Jul 2005
    Posts
    32
    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?

  8. #8
    Join Date
    Nov 2004
    Location
    Norway
    Posts
    1,560
    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....
    Last edited by sjalle; 07-25-2005 at 04:10 AM.
    eschew obfuscation

  9. #9
    Join Date
    Jul 2005
    Posts
    32
    Hi

    Might take that line out then...!

    Have attached the zip file
    Attached Files

  10. #10
    Join Date
    Nov 2004
    Location
    Norway
    Posts
    1,560
    I get this when i try to load it (is the Sun Java Console)

    Code:
    java.lang.ClassNotFoundException: CopyBinarySearchTreeDisplay.class
    eschew obfuscation

  11. #11
    Join Date
    Nov 2004
    Location
    Norway
    Posts
    1,560

    Got it.

    I added a package directive on top of each java source file.
    Code:
    package devx1;
    This means that when compiled the class files are stored in folder "devx1"
    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 devx1 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.
    Last edited by sjalle; 07-25-2005 at 05:37 AM.
    eschew obfuscation

  12. #12
    Join Date
    Jul 2005
    Posts
    32
    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?

  13. #13
    Join Date
    Nov 2004
    Location
    Norway
    Posts
    1,560
    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.
    eschew obfuscation

  14. #14
    Join Date
    Jul 2005
    Posts
    32
    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!

  15. #15
    Join Date
    Nov 2004
    Location
    Norway
    Posts
    1,560
    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

    Good Luck
    Last edited by sjalle; 07-25-2005 at 06:24 AM.
    eschew obfuscation

Similar Threads

  1. Creating a link list file and loading a lib
    By ram_son in forum VB Classic
    Replies: 8
    Last Post: 03-29-2005, 04:09 PM
  2. Replies: 3
    Last Post: 03-01-2005, 03:42 AM
  3. Replies: 0
    Last Post: 11-19-2002, 08:11 AM
  4. JApplet class not loading on html file
    By Sam in forum Architecture and Design
    Replies: 0
    Last Post: 02-04-2001, 01:57 AM
  5. Replies: 1
    Last Post: 02-02-2001, 10:22 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links