applet单独运行的main一般这么写!希望有所帮助,呵呵
public static void main(String[] args) {
Applet1 applet = new Applet1();
applet.isStandalone = true;
Frame frame;
frame = new Frame() {
protected void processWindowEvent(WindowEvent e) {
super.processWindowEvent(e);
if (e.getID() == WindowEvent.WINDOW_CLOSING) {
System.exit(0);
}
}
public synchronized void setTitle(String title) {
super.setTitle(title);
enableEvents(AWTEvent.WINDOW_EVENT_MASK);
}
};
frame.setTitle("Applet Frame");
frame.add(applet, BorderLayout.CENTER);
applet.init();
applet.start();
frame.setSize(400,320);
Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
frame.setLocation((d.width - frame.getSize().width) / 2, (d.height - frame.getSize().height) / 2);
frame.setVisible(true);
}
public static void main(String[] args) {
Applet1 applet = new Applet1();
applet.isStandalone = true;
Frame frame;
frame = new Frame() {
protected void processWindowEvent(WindowEvent e) {
super.processWindowEvent(e);
if (e.getID() == WindowEvent.WINDOW_CLOSING) {
System.exit(0);
}
}
public synchronized void setTitle(String title) {
super.setTitle(title);
enableEvents(AWTEvent.WINDOW_EVENT_MASK);
}
};
frame.setTitle("Applet Frame");
frame.add(applet, BorderLayout.CENTER);
applet.init();
applet.start();
frame.setSize(400,320);
Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
frame.setLocation((d.width - frame.getSize().width) / 2, (d.height - frame.getSize().height) / 2);
frame.setVisible(true);
}
解决方案 »
- -------------------大家在开发系统的时候,都是开发到什么阶段开始在数据库建立VIEW---------------------
- jsp生成动态树
- 如果JAVA死了,那谁将取代JAVA的地位?
- 新手问题...关于JB返回SQL数据的问题!
- 异常求助200分,在线等。
- 如何让时间类型数据只显示其月份?
- java中 switch case 语句的用法问题!
- 为什么我写的AspectJ for JBuilder程序可以通过编译,却无法运行?
- 请教:如何用简单的方式将某个指定目录下的几十个jar文件在CLASSPATH变量中注册?(50)
- jview的问题,高手请进~
- 真怪,为什么我的BufferReader.read会block在那边
- java中如何实现类似vb中的chr()函数的功能?
appletviewer xxx.htm
其中xxx.htm是包含该applet的网页
<body>
<applet codebase="." code="Drawpics.class"width=""height="">
</applet>
</body>
</html>
运行这个*.html.
//</applet>
在类最上面加上这一段
用appletviewer命令执行