Results 1 to 19 of 19

Thread: Java Applet

  1. #1

    Thread Starter
    PowerPoster eranga262154's Avatar
    Join Date
    Jun 2006
    Posts
    2,201

    Wink Java Applet

    Hey....

    I have created very simple Java Applet. Here the coding has done my-self.


    This is the Java File.

    import java.awt.Graphics;

    public class HelloWorldApplet extends java.applet.Applet
    {
    public void paint(Graphics g)
    {
    g.drawString("Hello World",5,25);
    }
    }

    This is HTML File.

    <html>
    <head>
    <title>Hello To Everyone !</title>
    </head>
    <body>
    <p>My Java Applet Says:
    <applet code = "HelloWorldApplet.class" width=150 height=25></applet>
    </p>
    </body>
    </html>


    Then I used IE6.0 and Applet Viewer to run the applet. But it gives different outputs.


    Output on IE6.0 and Applet Viewer as follws.



    I’m confusing with that. Can someone help me to where I’m going wrong?
    Attached Images Attached Images   

  2. #2
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594

    Re: Java Applet

    Please use code tags whenever posting code.

    I don't think IE supports the applet tag, or if it does, it might attempt to use the broken MS JVM.
    Use the object tag with the correct classid instead.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  3. #3
    Arabic Poster ComputerJy's Avatar
    Join Date
    Nov 2005
    Location
    Happily misplaced
    Posts
    2,513

    Re: Java Applet

    You can Open Java Console from the IE page (Right click the Applet) and check if any errors occurred during run-time

    EDIT: CornedBee is %100 right, you should use the Object tag
    Last edited by ComputerJy; Sep 9th, 2006 at 02:56 PM.
    "I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
    My Blog

  4. #4

    Thread Starter
    PowerPoster eranga262154's Avatar
    Join Date
    Jun 2006
    Posts
    2,201

    Wink Re: Java Applet

    Quote Originally Posted by CornedBee
    Please use code tags whenever posting code.

    I don't think IE supports the applet tag, or if it does, it might attempt to use the broken MS JVM.
    Use the object tag with the correct classid instead.
    Please can you explain this little.

    Thanks

  5. #5
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594

    Re: Java Applet

    Which part, the first or the second?
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  6. #6
    Frenzied Member System_Error's Avatar
    Join Date
    Apr 2004
    Posts
    1,111

    Re: Java Applet

    Look for a little mug of coffee in your taskbar. Right click and view the console. Any errors will be listed there.

    PS: What about a screenshot of these differences... Applet tag has always worked for me (cross browser), so I'm not sure what kind of problems you're having.

  7. #7
    Frenzied Member System_Error's Avatar
    Join Date
    Apr 2004
    Posts
    1,111

    Re: Java Applet

    Sorry about that, you did post screenies.


    It looks like IE doesn't have an updated JRE or something. Goto internet options and make sure the java checkbox is checked. If it is checked, then uncheck it and try again (make sure you check it back if this does not work).

  8. #8
    Arabic Poster ComputerJy's Avatar
    Join Date
    Nov 2005
    Location
    Happily misplaced
    Posts
    2,513

    Re: Java Applet

    Quote Originally Posted by System_Error
    Look for a little mug of coffee in your taskbar. Right click and view the console. Any errors will be listed there.

    PS: What about a screenshot of these differences... Applet tag has always worked for me (cross browser), so I'm not sure what kind of problems you're having.
    lol, looks like I was a little faster

    Quote Originally Posted by System_Error
    It looks like IE doesn't have an updated JRE or something. Goto internet options and make sure the java checkbox is checked. If it is checked, then uncheck it and try again (make sure you check it back if this does not work).
    That's right, you can make sure java is enabled for any browser from the Java shortcut on the Control Panel
    Java==>Advanced Tab==>Settings==> <Applet> tag support.
    If you didn't have any of these you must re-install the JRE
    "I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
    My Blog

  9. #9

    Thread Starter
    PowerPoster eranga262154's Avatar
    Join Date
    Jun 2006
    Posts
    2,201

    Wink Re: Java Applet

    Quote Originally Posted by CornedBee
    Which part, the first or the second?
    Second part, please
    “victory breeds hatred, the defeated live in pain; happily the peaceful live giving up victory and defeat” - Gautama Buddha

  10. #10
    Arabic Poster ComputerJy's Avatar
    Join Date
    Nov 2005
    Location
    Happily misplaced
    Posts
    2,513

    Re: Java Applet

    Quote Originally Posted by eranga262154
    Second part, please
    read this
    "I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
    My Blog

  11. #11

    Thread Starter
    PowerPoster eranga262154's Avatar
    Join Date
    Jun 2006
    Posts
    2,201

    Wink Re: Java Applet

    Quote Originally Posted by ComputerJy
    read this
    I go through your link,

    But still comes with same output,

    My output should be as follows.

    My Java Applet Says: Hello World

    That bold text should be printed on a dark area, isn't it? Still have the same output.
    “victory breeds hatred, the defeated live in pain; happily the peaceful live giving up victory and defeat” - Gautama Buddha

  12. #12
    Arabic Poster ComputerJy's Avatar
    Join Date
    Nov 2005
    Location
    Happily misplaced
    Posts
    2,513

    Re: Java Applet

    You can Open Java Console from the IE page (Right click the Applet) and check if any errors occurred during run-time
    if you couldn't find out what is wrong, please show us the stack-trace of the Exception
    "I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
    My Blog

  13. #13

    Thread Starter
    PowerPoster eranga262154's Avatar
    Join Date
    Jun 2006
    Posts
    2,201

    Re: Java Applet

    OK,

    holdon, I'll test it and send my response here. Thanks
    “victory breeds hatred, the defeated live in pain; happily the peaceful live giving up victory and defeat” - Gautama Buddha

  14. #14
    Lively Member
    Join Date
    Dec 2005
    Posts
    68

    Re: Java Applet

    It could be that your browser does not have legacy support. When you set attributes, they should be in quotes:

    <applet code = "HelloWorldApplet.class" width="150" height="25"></applet>

    Also, make sure that your setting your page color so that it draws in black (or whatever color you want).

    Code:
    g.setColor (Color.black);
    g.drawString("Hello World",5,25);
    It's good programming to set the color before you draw anything, even though it should draw in black by default. You may consider setting the background color before you draw to see if that even shows up when viewing from IE.

    Code:
    setBackground (Color.blue);
    g.setColor (Color.black);
    g.drawString("Hello World",5,25);
    Last edited by lunchboxtheman; Oct 9th, 2006 at 11:55 AM.

  15. #15
    Arabic Poster ComputerJy's Avatar
    Join Date
    Nov 2005
    Location
    Happily misplaced
    Posts
    2,513

    Re: Java Applet

    Quote Originally Posted by lunchboxtheman
    It could be that your browser does not have legacy support. When you set attributes, they should be in quotes:
    No you don't
    Quote Originally Posted by lunchboxtheman
    Also, make sure that your setting your page color so that it draws in black (or whatever color you want).
    It's poor programming (Lack of efficiency) when you put unnecessary instructions in your code
    "I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
    My Blog

  16. #16
    Lively Member
    Join Date
    Dec 2005
    Posts
    68

    Re: Java Applet

    Quote Originally Posted by ComputerJy
    No you don't
    It's poor programming (Lack of efficiency) when you put unnecessary instructions in your code
    Welcome to the world of XHTML. Read up on it. Most browsers are phasing out HTML support, and the new standard is XHTML. It is considered good programming to put attributes in quotes, though in basic HTML it is NOT required. Make sure you know what your talking about before you post false information.

    (It didn't quote your statement about my comments on quotes correctly)

  17. #17
    Arabic Poster ComputerJy's Avatar
    Join Date
    Nov 2005
    Location
    Happily misplaced
    Posts
    2,513

    Re: Java Applet

    Perhaps, you'd go and read my post again.
    About the XHTML I just said "No you don't", and you really don't have to write XHTML, HTML still works for all browsers

    The Part you quoted was about the "setColor" which is totally unnecessary
    "I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
    My Blog

  18. #18
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594

    Re: Java Applet

    Quote Originally Posted by lunchboxtheman
    Welcome to the world of XHTML. Read up on it. Most browsers are phasing out HTML support, and the new standard is XHTML.
    Browsers phasing out HTML? What planet do you live on? XHTML has huge acceptance issues. IE still, even in version 7, doesn't really support XHTML. XHTML 2, from what I'm seeing on the W3C html list, is in high risk of being stillborn. The W3C itself is being criticized by many professionals, and the WHAT-WG is busily writing a HTML 5 standard.
    I give HTML another 10 years at least, unless virtual reality becomes the primary net form first.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  19. #19

    Thread Starter
    PowerPoster eranga262154's Avatar
    Join Date
    Jun 2006
    Posts
    2,201

    Wink Re: Java Applet

    Quote Originally Posted by lunchboxtheman
    attributes, they should be in quotes:

    <applet code = "HelloWorldApplet.class" width="150" height="25"></applet>
    I try this, but not get fine output. I think misses the quotes is much effected to my code, isn't it?
    “victory breeds hatred, the defeated live in pain; happily the peaceful live giving up victory and defeat” - Gautama Buddha

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width