我在通过 Web Start/Applet 部署 Swing 应用程序时遇到困难

发布于 2024-12-21 10:14:31 字数 2986 浏览 3 评论 0原文

我构建了一个需要从浏览器运行的 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>

JNLP

    <?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>

Java

    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();
     }
    }

I have constructed a Swing Application that needs to be run from a browser. Here is the code for the HTML file, JNLP file, and the Swing Applications Code. Is there a clear reason why this is not working?

Its posted at www.nestroia.com/netbeans.html

Thanks, all help is greatly appreciated.

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>

JNLP

    <?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>

Java

    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();
     }
    }

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

ぃ弥猫深巷。 2024-12-28 10:14:31

我注意到的第一件事是,应该使用 JNLP 中的 application-desc 而不是 applet-desc 来启动 JFrame。但为了获得比我的眼睛所能提供的更好的验证,请使用 JaNeLA


如果您要回答 aardvarkk 的问题来解释“不工作”具体意味着什么,这也会有很大帮助。

The first thing I notice is that a JFrame should be launched using an application-desc in the JNLP, rather than an applet-desc. But for a far better validation than my eye can supply, use JaNeLA.


It would also help immensely if you were to answer aardvarkk's question to explain What does "not working" mean, specifically?

云柯 2024-12-28 10:14:31

NetBenas_SwingFrame

拼写错误不是吗(主类)。

NetBenas_SwingFrame

Typo isn't it (main-class).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文