我构建了一个需要从浏览器运行的Swing应用程序。以下是HTML文件,JNLP文件和Swing应用程序代码的代码。有没有明确的理由说明这不起作用?
发布于www.nestroia.com/netbeans.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();
}
}
答案 0 :(得分:3)
我注意到的第一件事是应该使用JNLP中的JFrame
而不是application-desc
启动applet-desc
。但是为了获得比我的眼睛更好的验证,请使用JaNeLA。
如果你回答aardvarkk的问题来解释“不工作”是什么意思,特别是
,这也会有很大帮助答案 1 :(得分:2)
<强> NetBenas_SwingFrame 强>
错字不是它(主要类别)。