Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Page 1 of 2 12 LastLast
Results 1 to 25 of 34

Thread: Applet isn't showing up. Perhaps it's a browser fault.

  1. #1
    Banned
    Join Date
    May 2010
    Location
    North Central Illinois
    Posts
    1,631
    My Mood
    Sleepy
    Thanks
    390
    Thanked 112 Times in 110 Posts

    Default Applet isn't showing up. Perhaps it's a browser fault.

    My applet isn't showing up. I finally got it to say that my browser is ignoring the applet tag, which I'm guessing was the error message if it couldn't display it, based on that code sample I found.

    I tried even a simple Hello World Applet and it's not working. (Maybe I shouldn't have made the html file part of the jar)

    What am I doing wrong?
    Attached Files Attached Files


  2. #2
    Forum VIP
    Join Date
    Jul 2010
    Posts
    1,676
    Thanks
    25
    Thanked 329 Times in 305 Posts

    Default Re: Applet isn't showing up. Perhaps it's a browser fault.

    Post your html code. I tried to view it myself, but it crashed my browser...
    NOTE TO NEW PEOPLE LOOKING FOR HELP ON FORUM:

    When asking for help, please follow these guidelines to receive better and more prompt help:
    1. Put your code in Java Tags. To do this, put [highlight=java] before your code and [/highlight] after your code.
    2. Give full details of errors and provide us with as much information about the situation as possible.
    3. Give us an example of what the output should look like when done correctly.

    Join the Airline Management Simulation Game to manage your own airline against other users in a virtual recreation of the United States Airline Industry. For more details, visit: http://airlinegame.orgfree.com/

  3. #3
    Banned
    Join Date
    May 2010
    Location
    North Central Illinois
    Posts
    1,631
    My Mood
    Sleepy
    Thanks
    390
    Thanked 112 Times in 110 Posts

    Default Re: Applet isn't showing up. Perhaps it's a browser fault.

    HTML Code:
    <html>
    <head> <title> Hello World Applet </title> </head>
    <body>
    <applet code="HelloWorldApplet.class" 
            codebase="C:/Users/Wenguin/Documents/Applet Folder 2/"
            archive="HelloWorldAppletProject.jar"
            width="600" height="95">
        
    
    Your browser is completely ignoring the &lt;APPLET&gt; tag!
    </applet>
    <APPLET CODEBASE=class 
    
    CODE="C:/Users/Wenguin/Documents/Applet Folder 
    
    2/HelloWorldApplet.class" WIDTH=300 HEIGHT=400>
    </APPLET>
    <OBJECT CLASSID="HelloWorldApplet.class" 
    
    CODEBASE="C:/Users/Wenguin/Documents/Applet Folder 2\">
    
    </OBJECT>
    </body>
    </html>

  4. #4
    Forum VIP
    Join Date
    Jul 2010
    Posts
    1,676
    Thanks
    25
    Thanked 329 Times in 305 Posts

    Default Re: Applet isn't showing up. Perhaps it's a browser fault.

    Why do you have two applet tags? Also, when the program crashes in the browser, you should be able to click on the applet and bring up a window with an error message. What is that error message?
    NOTE TO NEW PEOPLE LOOKING FOR HELP ON FORUM:

    When asking for help, please follow these guidelines to receive better and more prompt help:
    1. Put your code in Java Tags. To do this, put [highlight=java] before your code and [/highlight] after your code.
    2. Give full details of errors and provide us with as much information about the situation as possible.
    3. Give us an example of what the output should look like when done correctly.

    Join the Airline Management Simulation Game to manage your own airline against other users in a virtual recreation of the United States Airline Industry. For more details, visit: http://airlinegame.orgfree.com/

  5. #5
    Banned
    Join Date
    May 2010
    Location
    North Central Illinois
    Posts
    1,631
    My Mood
    Sleepy
    Thanks
    390
    Thanked 112 Times in 110 Posts

    Default Re: Applet isn't showing up. Perhaps it's a browser fault.

    When I got the error message, it used to be that it couldn't find the class.

    However, now it says that the browsers all don't like the <applet> tag.

    The applet compiles. The jar won't run but, then again, you probably can't run a jar for an applet like you could a jar for a JFrame.

    Also, as I had no main class, perhaps it didn't make the jar correctly.

    I tried both types of tags as I heard the applet tag was deprecated. However, I couldn't quite get the object tag to work. I've been looking at a few tutorials for how to use the applet tag and also the object tag with applets but it's still never going quite right and goes wrong in some way or other. No matter what I seem to do.

    I was trying different ways of using the tags to see if one of them actually worked, but it hasn't yet.

  6. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Applet isn't showing up. Perhaps it's a browser fault.

    Try making a simple test case:
    have only one <APPLET tag,
    put the html and jar file in same folder (no codebase)
    If you don't understand my answer, don't ignore it, ask a question.

  7. The Following User Says Thank You to Norm For This Useful Post:

    javapenguin (May 13th, 2012)

  8. #7
    Forum VIP
    Join Date
    Jul 2010
    Posts
    1,676
    Thanks
    25
    Thanked 329 Times in 305 Posts

    Default Re: Applet isn't showing up. Perhaps it's a browser fault.

    Can you copy and paste the actual error message?
    NOTE TO NEW PEOPLE LOOKING FOR HELP ON FORUM:

    When asking for help, please follow these guidelines to receive better and more prompt help:
    1. Put your code in Java Tags. To do this, put [highlight=java] before your code and [/highlight] after your code.
    2. Give full details of errors and provide us with as much information about the situation as possible.
    3. Give us an example of what the output should look like when done correctly.

    Join the Airline Management Simulation Game to manage your own airline against other users in a virtual recreation of the United States Airline Industry. For more details, visit: http://airlinegame.orgfree.com/

  9. The Following User Says Thank You to aussiemcgr For This Useful Post:

    javapenguin (May 13th, 2012)

  10. #8
    Junior Member
    Join Date
    Nov 2011
    Posts
    19
    My Mood
    Inspired
    Thanks
    1
    Thanked 1 Time in 1 Post

    Default Re: Applet isn't showing up. Perhaps it's a browser fault.

    I got it to run from your zip file, the java code is fine, you have just messed up a bit in the html, I've never made an applet before but I guessed there shouldn't be multiple applet tags, so I removed all but one of them, I also made the html links relative so they don't need to be on a computer with the location C:\users\*yourusersname* etc. the html and helloworldapplet.class just have to be in the same directory, leave everything the same but change the html code to be this
    <html>
    <head> <title> Hello World Applet </title> </head>
    <body>
    <APPLET CODEBASE=. CODE="HelloWorldApplet.class" WIDTH=300 HEIGHT=400>
    </APPLET>
    </body>
    </html>

    edit:
    also in your source java code you spelt the world in hello world wrong (doesn't actually matter I know)

  11. The Following User Says Thank You to handuel For This Useful Post:

    javapenguin (May 13th, 2012)

  12. #9
    Banned
    Join Date
    May 2010
    Location
    North Central Illinois
    Posts
    1,631
    My Mood
    Sleepy
    Thanks
    390
    Thanked 112 Times in 110 Posts

    Default Re: Applet isn't showing up. Perhaps it's a browser fault.

    How do you get it to show the GUI form like it does with the JMenuBar it has in the IDE testing?

    All I'm getting is a sort of embedded app, not a free-standing window. Is something wrong?

  13. #10
    Banned
    Join Date
    May 2010
    Location
    North Central Illinois
    Posts
    1,631
    My Mood
    Sleepy
    Thanks
    390
    Thanked 112 Times in 110 Posts

    Default Re: Applet isn't showing up. Perhaps it's a browser fault.

    Any idea how to get a JApplet to call another JApplet?

    (Like you would with a JFrame subclass having another JFrame subclass, i.e. a button in one JFrame that opens a new JFrame.)

  14. #11
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Applet isn't showing up. Perhaps it's a browser fault.

    If the applets are being shown in the same Html page, the AppletContext's getApplets() method will return a reference to the other applets. Those references can be used to call another applet.
    If you don't understand my answer, don't ignore it, ask a question.

  15. #12
    Banned
    Join Date
    May 2010
    Location
    North Central Illinois
    Posts
    1,631
    My Mood
    Sleepy
    Thanks
    390
    Thanked 112 Times in 110 Posts

    Default Re: Applet isn't showing up. Perhaps it's a browser fault.

    Do you use that in the java code or the html page? How do code that exactly?

  16. #13
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Applet isn't showing up. Perhaps it's a browser fault.

    I was talking about a java class and method. With 1500+ posts I assume that you know what they are and can read their API doc and do a search for examples.

    Try writing two simple applets that use the mentioned classes & methods, put references to them into an html page with <Applet tags and see what happens. Print out the results.
    If you don't understand my answer, don't ignore it, ask a question.

  17. #14
    Banned
    Join Date
    May 2010
    Location
    North Central Illinois
    Posts
    1,631
    My Mood
    Sleepy
    Thanks
    390
    Thanked 112 Times in 110 Posts

    Default Re: Applet isn't showing up. Perhaps it's a browser fault.

    AppletContext is an interface. I decided to Google it. However, it appears that neither Applet nor JApplet implement it.

    I'm not that familiar with Enumeration though.

    Also, another reason why I'd been using the "object" tag is because I read that the Applet tag is deprecated and hence it may not work in future webpages.

  18. #15
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Applet isn't showing up. Perhaps it's a browser fault.

    Look at the Applet class. It has a method to get the AppletContext that can be used to call the getApplets() method.
    If you don't understand my answer, don't ignore it, ask a question.

  19. #16
    Banned
    Join Date
    May 2010
    Location
    North Central Illinois
    Posts
    1,631
    My Mood
    Sleepy
    Thanks
    390
    Thanked 112 Times in 110 Posts

    Default Re: Applet isn't showing up. Perhaps it's a browser fault.

    Ok, now I'm getting an enumeration of applets. But what do I do with it?

    How do I call another applet. I thought merely using an object would do it.

  20. #17
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Applet isn't showing up. Perhaps it's a browser fault.

    The methods I posted will get a reference to other Applets being displayed by the browser in the same html page. That reference can be used to call methods in the other applet.
    If you don't understand my answer, don't ignore it, ask a question.

  21. #18
    Forum VIP
    Join Date
    Jul 2010
    Posts
    1,676
    Thanks
    25
    Thanked 329 Times in 305 Posts

    Default Re: Applet isn't showing up. Perhaps it's a browser fault.

    I don't exactly follow what you are wanting to do. Are you wanting to swap out applets during runtime or something? Like have one applet replace itself with a different applet?
    NOTE TO NEW PEOPLE LOOKING FOR HELP ON FORUM:

    When asking for help, please follow these guidelines to receive better and more prompt help:
    1. Put your code in Java Tags. To do this, put [highlight=java] before your code and [/highlight] after your code.
    2. Give full details of errors and provide us with as much information about the situation as possible.
    3. Give us an example of what the output should look like when done correctly.

    Join the Airline Management Simulation Game to manage your own airline against other users in a virtual recreation of the United States Airline Industry. For more details, visit: http://airlinegame.orgfree.com/

  22. #19
    Banned
    Join Date
    May 2010
    Location
    North Central Illinois
    Posts
    1,631
    My Mood
    Sleepy
    Thanks
    390
    Thanked 112 Times in 110 Posts

    Default Re: Applet isn't showing up. Perhaps it's a browser fault.

    So, I can't have a JApplet call other JApplets with an ActionListener of a JButton.

  23. #20
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Applet isn't showing up. Perhaps it's a browser fault.

    You can have one class create an instance of another class and call its its methods using that instance.
    It can be done inside of a method like the action listener of a button.

    What do you expect to happen when you call that created instance's methods?
    If you don't understand my answer, don't ignore it, ask a question.

  24. #21
    Banned
    Join Date
    May 2010
    Location
    North Central Illinois
    Posts
    1,631
    My Mood
    Sleepy
    Thanks
    390
    Thanked 112 Times in 110 Posts

    Default Re: Applet isn't showing up. Perhaps it's a browser fault.

    A new applet to pop up or a new window to come. That's what I had been hoping for.

  25. #22
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Applet isn't showing up. Perhaps it's a browser fault.

    You will have to write all the code for that. The browser takes care of the applet referenced in the html page by the <applet tag. If you want something more to happen with things the browser doesn't know about, your code will have to manage it.
    If you don't understand my answer, don't ignore it, ask a question.

  26. #23
    Banned
    Join Date
    May 2010
    Location
    North Central Illinois
    Posts
    1,631
    My Mood
    Sleepy
    Thanks
    390
    Thanked 112 Times in 110 Posts

    Default Re: Applet isn't showing up. Perhaps it's a browser fault.

    How would I handle that? I thought that a mere object reference would do it.

  27. #24
    Forum VIP
    Join Date
    Jul 2010
    Posts
    1,676
    Thanks
    25
    Thanked 329 Times in 305 Posts

    Default Re: Applet isn't showing up. Perhaps it's a browser fault.

    Just to make sure, are you aware of the differences between Applications and Applets (I ask because of your reference to JFrames earlier and your mention of new applets popping up)? Consider that JApplet inherits from Panel (meaning a JApplet is a Panel) and that JFrame inherits from Window (meaning JFrame is a Window). A JApplet cannot be treated the same as a JFrame. They are VERY different things.
    NOTE TO NEW PEOPLE LOOKING FOR HELP ON FORUM:

    When asking for help, please follow these guidelines to receive better and more prompt help:
    1. Put your code in Java Tags. To do this, put [highlight=java] before your code and [/highlight] after your code.
    2. Give full details of errors and provide us with as much information about the situation as possible.
    3. Give us an example of what the output should look like when done correctly.

    Join the Airline Management Simulation Game to manage your own airline against other users in a virtual recreation of the United States Airline Industry. For more details, visit: http://airlinegame.orgfree.com/

  28. #25
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Applet isn't showing up. Perhaps it's a browser fault.

    Go read up on how applets work and what their relationship with the browser is. The browser controls the GUI for the applet.
    If you don't understand my answer, don't ignore it, ask a question.

Page 1 of 2 12 LastLast

Similar Threads

  1. [SOLVED] Why doesn't my Applet show up in my browser?
    By SendBorg in forum Java Applets
    Replies: 3
    Last Post: January 29th, 2012, 08:30 AM
  2. Java applet on web showing gray box
    By MyName in forum Java Applets
    Replies: 6
    Last Post: December 2nd, 2011, 03:53 PM
  3. How to run Applet with Ms Sql connectivity in browser
    By mayanksmart4 in forum Java Applets
    Replies: 1
    Last Post: November 22nd, 2011, 09:57 AM
  4. HELP! My applet won't run on a web browser....
    By coolidge in forum Java Applets
    Replies: 4
    Last Post: October 21st, 2011, 08:52 AM
  5. Soap With Attachment AXIS Fault
    By anoopasta in forum What's Wrong With My Code?
    Replies: 1
    Last Post: November 23rd, 2010, 11:09 AM