Applet help

Discussion in 'Java' started by greyham, Feb 7, 2005.

  1. greyham

    greyham Guest

    I've developed a number of applets before but now new ones don't seem
    to work. I've got a simple example...

    import java.applet.*;
    import java.awt.*;
    public class testing extends Applet {
    public void paint(Graphics g) {
    int i=0;
    g.drawRect(50,50,60,60);
    }//paint
    }//class

    It compiles fine and I have a html page (testing.html) that reads...

    <html>
    <body>
    <applet code="testing.class" WIDTH="200" HEIGHT="200"</applet>
    </body>
    </html>

    When I view the page in IE, I get a grey rectangle and the error at the
    bottom says it can't find testing.class. I keep both in the same
    directory too. When I run >appletviewer -debug testing.html, I get:

    Initializing jdb ...
    >run

    run sun.applet.Main testing.html
    Set uncaught java.lang.Throwable
    Set deferred uncaught java.lang.Throwable
    >

    VM Started:
    The application exited

    And that's it. Any thoughts? Thanks
     
    greyham, Feb 7, 2005
    #1
    1. Advertising

  2. greyham

    Guest

    Is the HTML code exact? In the code you have, you are missing a >
     
    , Feb 7, 2005
    #2
    1. Advertising

  3. greyham

    Last Timer Guest

    You may have to use sun's HtmlConverter and enclose the applet class in
    <object > </object> tags.
     
    Last Timer, Feb 7, 2005
    #3
  4. greyham

    greyham Guest

    Thanks for the error, you're right. So it now works with appletviewer
    and I see the rectangle and have time to close it, but I still get the
    'uncaught' lines running the debugger. IE also doesn't find the class
    file too...?
     
    greyham, Feb 7, 2005
    #4
  5. greyham

    Guest

    I ran appletviewer with the debugger on my machine, and I didn't get an
    error. I'm run 1.4.0
     
    , Feb 7, 2005
    #5
  6. On 7 Feb 2005 12:28:36 -0800, greyham wrote:

    > When I view the page in IE, I get a grey rectangle and the error at the
    > bottom says it can't find testing.class.


    You probably need to compile the applet to work for the 1.1 (MS)VM,
    as it appears the IE you speak of is using it.
    <http://www.physci.org/codes/javafaq.jsp#appletie>

    --
    Andrew Thompson
    http://www.PhySci.org/codes/ Web & IT Help
    http://www.PhySci.org/ Open-source software suite
    http://www.1point1C.org/ Science & Technology
    http://www.LensEscapes.com/ Images that escape the mundane
     
    Andrew Thompson, Feb 9, 2005
    #6
  7. On 7 Feb 2005 12:40:33 -0800, Last Timer wrote:

    > You may have to use sun's HtmlConverter and enclose the applet class in
    > <object > </object> tags.


    Certainly not for the code quoted, which is compatible with even
    the MSVM (Java 1.1.4).

    HTMLConverter is a rather poor alternative in any case.
    <http://www.physci.org/codes/javafaq.jsp#version>

    Since the code is 1.1 compatible, it makes sense to
    stick with the <applet> element.

    If it were 1.2, use the JavaVersionApplet and the <applet> element.

    If the code were 1.3+, use WebStart.

    --
    Andrew Thompson
    http://www.PhySci.org/codes/ Web & IT Help
    http://www.PhySci.org/ Open-source software suite
    http://www.1point1C.org/ Science & Technology
    http://www.LensEscapes.com/ Images that escape the mundane
     
    Andrew Thompson, Feb 9, 2005
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Rob Love

    applet vs. canvas in applet

    Rob Love, Jul 7, 2003, in forum: Java
    Replies:
    1
    Views:
    626
    Liu, Chunyen
    Jul 7, 2003
  2. webster
    Replies:
    0
    Views:
    863
    webster
    Jul 20, 2003
  3. Andrew Thompson
    Replies:
    0
    Views:
    417
    Andrew Thompson
    Aug 5, 2003
  4. Blah Blah
    Replies:
    0
    Views:
    1,437
    Blah Blah
    Aug 13, 2003
  5. Jade
    Replies:
    3
    Views:
    934
    Roedy Green
    Aug 14, 2003
Loading...

Share This Page