Applet不用变。加入 一个Main方法就可以,比如:public static void main(String []s) {
Frame x = new Frame("ok");
x.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent ex) {
System.exit(0); }});
x.add(yourapplet); //这句把APPLET加入窗口。
……剩余是设置窗口并显示即可。
Frame x = new Frame("ok");
x.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent ex) {
System.exit(0); }});
x.add(yourapplet); //这句把APPLET加入窗口。
……剩余是设置窗口并显示即可。
YourApplet applet = new YourApplet();
applet.init();
applet.start();
JFrame frame = new JFrame();
frame.setContentPane(applet.getContentPane());
frame.setSize(new Dimension(900,650));
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
frame.setVisible(true);
}
我是针对JApplet的,用了JFrame。你也可以如上用Frame.
道理是设置frame的容器面板为applet的容器面板。