应该是
1 构造
2 init()
3 start()用下面的测试程序可以看出package tj01;import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import javax.swing.*;
import java.util.Date;/**
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2004</p>
* <p>Company: </p>
* @author not attributable
* @version 1.0
*/public class Applet1 extends JApplet {
private boolean isStandalone = false;
public String str="运行顺序测试:\n";
JToggleButton jToggleButton1 = new JToggleButton();
JButton jButton1 = new JButton(); //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() {
str+="\t构造函数\n";
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
} //Initialize the applet
public void init() {
str+="\tinit()\n";
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
} public void start() {
str+="\tstart()\n";
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
//Component initialization
private void jbInit() throws Exception {
jToggleButton1.setText(str);
this.setSize(new Dimension(400,300));
jButton1.setText("J按键一");
jButton1.addActionListener(new Applet1_jButton1_actionAdapter(this));
this.getContentPane().add(jToggleButton1, BorderLayout.CENTER);
this.getContentPane().add(jButton1, BorderLayout.WEST);
} //Get Applet information
public String getAppletInfo() {
return "Applet Information";
} //Get parameter info
public String[][] getParameterInfo() {
return null;
} //static initializer for setting look & feel
static {
try {
//UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
//UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
}
catch(Exception e) {
}
} void jButton1_actionPerformed(ActionEvent e) { }
}class Applet1_jButton1_actionAdapter implements java.awt.event.ActionListener {
Applet1 adaptee; Applet1_jButton1_actionAdapter(Applet1 adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton1_actionPerformed(e);
}
}
1 构造
2 init()
3 start()用下面的测试程序可以看出package tj01;import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import javax.swing.*;
import java.util.Date;/**
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2004</p>
* <p>Company: </p>
* @author not attributable
* @version 1.0
*/public class Applet1 extends JApplet {
private boolean isStandalone = false;
public String str="运行顺序测试:\n";
JToggleButton jToggleButton1 = new JToggleButton();
JButton jButton1 = new JButton(); //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() {
str+="\t构造函数\n";
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
} //Initialize the applet
public void init() {
str+="\tinit()\n";
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
} public void start() {
str+="\tstart()\n";
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
//Component initialization
private void jbInit() throws Exception {
jToggleButton1.setText(str);
this.setSize(new Dimension(400,300));
jButton1.setText("J按键一");
jButton1.addActionListener(new Applet1_jButton1_actionAdapter(this));
this.getContentPane().add(jToggleButton1, BorderLayout.CENTER);
this.getContentPane().add(jButton1, BorderLayout.WEST);
} //Get Applet information
public String getAppletInfo() {
return "Applet Information";
} //Get parameter info
public String[][] getParameterInfo() {
return null;
} //static initializer for setting look & feel
static {
try {
//UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
//UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
}
catch(Exception e) {
}
} void jButton1_actionPerformed(ActionEvent e) { }
}class Applet1_jButton1_actionAdapter implements java.awt.event.ActionListener {
Applet1 adaptee; Applet1_jButton1_actionAdapter(Applet1 adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton1_actionPerformed(e);
}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货