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.

Results 1 to 3 of 3

Thread: Embed SWING .JAR in Browser

  1. #1
    Junior Member
    Join Date
    Mar 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs up Embed SWING .JAR in Browser

    Hey folks,

    Got a small problem. I want to embed my Swing .JAR in my Browser and run it. All I get to see is a grey area, although it seems to load something for a couple of seconds.

    The HTML code is as following:
    HTML Code:
    <html>
    <head><title>Jass Client</title></head>
    <body>
    <applet code="jassclient.Main.class" name="Applet" archive="JassClient.jar" width="700" height="700">
    
    Not working...
    </applet>
    </body>
    </html>
    And the Java Code:

    /*
     * To change this template, choose Tools | Templates
     * and open the template in the editor.
     */
     
    package jassclient;
     
    import jassclient.display.GameGUI;
    import engine.Game;
    import engine.Gateway;
    import java.applet.Applet;
    import java.awt.Container;
    import javax.swing.JApplet;
    import javax.swing.SwingUtilities;
    /**
     *
     * @author ruffy
     */
    public class Main extends JApplet {
     
        private static GameGUI gameGUI;
     
        @Override
        public void init() {
            //Execute a job on the event-dispatching thread; creating this applet's GUI.
            try {
                SwingUtilities.invokeAndWait(new Runnable() {
                    public void run() {
     
                        GameGUI gameGUI = new GameGUI();
                        setContentPane(gameGUI);
     
                        //gameGUI = new GameGUI();
                        gameGUI.setVisible(true);
                    }
                });
            } catch (Exception e) {
                System.err.println("createGUI didn't complete successfully");
            }
     
        }
    }


    Any help would be greatly appreciated!


  2. #2
    Junior Member JJoelTheMan's Avatar
    Join Date
    Jun 2011
    Location
    Placerville, CA
    Posts
    2
    My Mood
    Amazed
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Embed SWING .JAR in Browser

    Great question! I am having the same problem as you. My .jar executes fine, but the browser doesn't show the applet. I also have a test Applet that I coded which I exported to a .jar and it runs successfully in the browser. If anyone can help we would definitely appreciate it. BTW ventrol if you find the answer would you be so kind as to keep me informed Thanks so much,

  3. #3
    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: Embed SWING .JAR in Browser

    Look at the browser's java console for error messages.

Similar Threads

  1. Embed Java inside Java?
    By ActionSplash in forum Java Theory & Questions
    Replies: 3
    Last Post: February 8th, 2011, 09:04 AM
  2. japplet - jtable - browser
    By jasonnuigi in forum AWT / Java Swing
    Replies: 4
    Last Post: January 2nd, 2011, 05:20 AM
  3. insert(embed) a file object (.txt file) in MS excel sheet using java.
    By jyoti.dce in forum What's Wrong With My Code?
    Replies: 1
    Last Post: August 12th, 2010, 08:16 AM
  4. Embed xterm in JFrame
    By stu1811 in forum AWT / Java Swing
    Replies: 4
    Last Post: July 28th, 2010, 07:33 AM
  5. how to get url, from browser in the socket class?
    By chinni in forum Java Networking
    Replies: 0
    Last Post: November 6th, 2009, 10:34 AM