我在通过 Web Start/Applet 部署 Swing 应用程序时遇到困难
我构建了一个需要从浏览器运行的 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我注意到的第一件事是,应该使用 JNLP 中的 application-desc 而不是 applet-desc 来启动 JFrame。但为了获得比我的眼睛所能提供的更好的验证,请使用 JaNeLA。
如果您要回答 aardvarkk 的问题来解释“不工作”具体意味着什么,这也会有很大帮助。
The first thing I notice is that a
JFrame
should be launched using anapplication-desc
in the JNLP, rather than anapplet-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?
NetBenas_SwingFrame
拼写错误不是吗(主类)。
NetBenas_SwingFrame
Typo isn't it (main-class).