既是applet又是application的java程序的关闭问题。
有一个既是applet又是application的java程序,当作为application运行时,点击windows窗口的X时,并不能关闭程序,而只能关闭进程,添加什么语句可以使用windows的X关闭程序呢?
代码如下:
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
/**
* <p> Title: </p>
* <p> Description: </p>
* <p> Copyright: Copyright (c) 2006 </p>
* <p> Company: </p>
* @author not attributable
* @version 1.0
*/
public class Applet1 extends Applet {
private boolean isStandalone = false;
JTabbedPane stradacTab = new JTabbedPane();
JPanel jPanel1 = new JPanel();
JPanel jPanel2 = new JPanel();
JScrollPane jScrollPane1 = new JScrollPane();
JTextField jTextField1 = new JTextField();
JComboBox jComboBox1 = new JComboBox();
JTextPane jTextPane1 = new JTextPane();
JButton jButton1 = new JButton();
JTextArea jTextArea1 = new JTextArea();
JToggleButton jToggleButton1 = new JToggleButton();
JButton jButton2 = new JButton();
JTextArea jTextArea2 = new JTextArea();
JEditorPane jEditorPane1 = new JEditorPane();
//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 Applet1() {
}
//Initialize the applet
public void init() {
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
//Component initialization
private void jbInit() throws Exception {
this.setLayout(null);
stradacTab.setBounds(new Rectangle(40, 18, 317, 260));
jPanel1.setBounds(new Rectangle(6, 51, 31, 52));
jPanel1.setLayout(null);
jPanel2.setBounds(new Rectangle(1, 129, 38, 87));
jButton1.setBounds(new Rectangle(56, 143, 93, 47));