applet是个panel,你直接把他勇于frame之类的就跟application一样了。
解决方案 »
- [求助]JDBC连接Oracle数据库
- 环境变量问题 谢谢了``
- sql难题,高手指教一下. 谢谢了
- !!!菜鸟在线等,java基础类库中有没有办法将String类数组一次性写入文件?
- 求高手点拨一个“JavaSE的程序中的"小异常"”.
- 求前辈详细说明几句AutoCAD脚本文件的功能
- 难道就没有人知道吗?
- 创建和使用接口问题,怎么出错?
- 假定,JAVAC.EXE和HELLOWORD.JAVA在一个目录里,我用JAVAC HELLOWORD.JAVA为什么不能编译成CLASS文件?如果我只想在命令行下编译怎么做?
- 学习JAVA者,来!
- 有关applet的html问题
- [急]JSP+Applet出错...
import java.awt.event.*;
import java.applet.*;
import javax.swing.*;
/**
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2004</p>
* <p>Company: </p>
* @author not attributable
* @version 1.0
*/public class TestApplet extends Applet {
private boolean isStandalone = false;
Button button1 = new Button(); //Get a parameter value
public String getParameter(String key, String def) {
return isStandalone ? System.getProperty(key, def) :
(getParameter(key) != null ? getParameter(key) : def);
} //Construct the applet
public TestApplet() {
}
//Main method
public static void main(String[] args) {
TestApplet applet = new TestApplet();
applet.isStandalone = true;
JFrame frame = new JFrame();
//EXIT_ON_CLOSE == 3
frame.setDefaultCloseOperation(3);
frame.setTitle("Applet Frame");
frame.getContentPane().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);
} //Initialize the applet
public void init() {
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
} //Component initialization
private void jbInit() throws Exception {
button1.setLabel("button1");
button1.addActionListener(new TestApplet_button1_actionAdapter(this));
this.add(button1, null);
} //Start the applet
public void start() {
} //Stop the applet
public void stop() {
} //Destroy the applet
public void destroy() {
} //Get Applet information
public String getAppletInfo() {
return "Applet Information";
} //Get parameter info
public String[][] getParameterInfo() {
return null;
} void button1_actionPerformed(ActionEvent e) {
if ("button1".equals( button1.getLabel())) {
button1.setLabel("按钮一");
}
else {
button1.setLabel("button1");
}
}
}class TestApplet_button1_actionAdapter implements java.awt.event.ActionListener {
TestApplet adaptee; TestApplet_button1_actionAdapter(TestApplet adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.button1_actionPerformed(e);
}
}