我已经构建了一个Swing应用程序,需要从浏览器运行它。这是HTML文件,JNLP文件和Swing应用程序代码的代码。是否有明确的原因为什么不起作用?

其发布在www.nestroia.com/netbeans.html

谢谢,非常感谢所有帮助。

的HTML

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="utf-8" />

        <!-- Always force latest IE rendering engine (even in intranet) & Chrome Frame
        Remove this if you use the .htaccess -->
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />

        <title>Nestroia.com</title>
        <meta name="description" content="" />
        <meta name="author" content="Artur Vieira" />

        <meta name="viewport" content="width=device-width; initial-scale=1.0" />

         <!-- Replace favicon.ico & apple-touch-icon.png in the root of your domain and
         delete these references -->
         <link rel="shortcut icon" href="/favicon.ico" />
         <link rel="apple-touch-icon" href="/apple-touch-icon.png" />
     </head>
     <body>
         <script src="http://www.java.com/js/deployJava.js"></script>
         <script>
         var attributes = { code:'NetBeans_SwingFrame',  width:800, height:600} ;
         var parameters = {jnlp_href: 'NetBeans_SwingFrame.jnlp'} ;
         deployJava.runApplet(attributes, parameters, '1.6');
         </script>
    </body>
    </html>


国民党

    <?xml version="1.0" encoding="UTF-8" ?>
    <jnlp spec="1.0+" codebase="" href="">
        <information>
            <title>NetBeans_SwingFrame</title>
            <vendor>Nestroia.com</vendor>
        </information>
        <resources>
            <!-- Application Resources -->
            <j2se version="1.6+"
              href="http://java.sun.com/products/autodl/j2se" />
            <jar href="NetBeans_SwingFrame.jar" main="true" />

        </resources>
        <applet-desc
            name="NetBeans_SwingFrame"
            main-class="netbeans_swingframe.NetBeans_SwingFrame"
            width="800"
            height="600">
        </applet-desc>
        <update check="background"/>
    </jnlp>


爪哇

    public class NetBeans_SwingFrame extends JFrame{
        public NetBeans_SwingFrame(){
            setTitle("Nestroia");
            setSize(800,600);
            setLocation(0,0);
            setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            setVisible(true);

            JLabel text = new JLabel("This is where the Application goes.");
            this.getContentPane().add(text,BorderLayout.NORTH);

     }
     /**
     * @param args the command line arguments
     */
     public static void main(String[] args) {
           NetBeans_SwingFrame main = new NetBeans_SwingFrame();
     }
    }

最佳答案

我注意到的第一件事是,应该使用JNLP中的JFrame而不是application-desc启动applet-desc。但是要使用我的眼睛无法提供的更好的验证,请使用JaNeLA



如果您要回答aardvarkk的问题来解释“不起作用”是什么意思,这也将极大地帮助您?

关于java - 我在通过Web Start/Applet部署Swing应用程序时遇到困难,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/8522743/

10-12 02:47