java的applet类的一个应用程序
package university;
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import com.borland.jbcl.layout.*;
/**
* <p>Title: applet</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;
String var0;
Canvas canvas1 = new Canvas();
Label label1 = new Label();
XYLayout xYLayout1 = new XYLayout();
Label label2 = new Label();
Choice choice1 = new Choice();
Button button1 = new Button();
Checkbox checkbox1 = new Checkbox();
Checkbox checkbox2 = new Checkbox();
Checkbox checkbox3 = new Checkbox();
Label label3 = new Label();
Choice choice2 = new Choice();
Button button2 = new Button();
Label label4 = new Label();
Choice choice3 = new Choice();
Label label5 = new Label();
Choice choice4 = new Choice();
Label label6 = new Label();
Choice choice5 = new Choice();
Choice choice6 = new Choice();
TextArea textArea1 = new TextArea();
//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 {
var0 = this.getParameter("param0", "");
}
catch(Exception e) {
e.printStackTrace();
}
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
//Component initialization
private void jbInit() throws Exception {
canvas1.setBackground(Color.orange);
this.setBackground(Color.orange);
this.setForeground(Color.black);
this.setLayout(xYLayout1);
label1.setAlignment(Label.LEFT);
label1.setBackground(Color.orange);
label1.setEnabled(true);
label1.setFont(new java.awt.Font("Dialog", 0, 16));
label1.setForeground(Color.yellow);
label1.setLocale(new java.util.Locale("zh", "CN", ""));
label1.setText("大学:");
label2.setBackground(Color.orange);
label2.setEnabled(true);
label2.setFont(new java.awt.Font("Dialog", 0, 16));
label2.setForeground(Color.green);
label2.setText("学科:");
button1.setBackground(Color.red);
button1.setFont(new java.awt.Font("Dialog", 0, 12));
button1.setLabel("确定");
button1.addActionListener(new Applet1_button1_actionAdapter(this));
checkbox1.setBackground(Color.magenta);
checkbox1.setFont(new java.awt.Font("Dialog", 1, 12));
checkbox1.setForeground(Color.yellow);
checkbox1.setLabel("国家重点学科");
checkbox1.setLocale(java.util.Locale.getDefault());
checkbox1.setState(false);
checkbox1.setVisible(true);
checkbox2.setBackground(Color.magenta);
checkbox2.setFont(new java.awt.Font("Dialog", 1, 12));
checkbox2.setForeground(Color.yellow);
checkbox2.setLabel("博士学位授予权");
checkbox3.setBackground(Color.magenta);
checkbox3.setFont(new java.awt.Font("Dialog", 1, 12));
checkbox3.setForeground(Color.yellow);
checkbox3.setLabel("具有两院院士");
label3.setBackground(Color.orange);
label3.setEnabled(true);
label3.setFont(new java.awt.Font("Dialog", 0, 12));
label3.setForeground(Color.green);
label3.setLocale(java.util.Locale.getDefault());
label3.setText("所在地区:");
button2.setActionCommand("确定");
button2.setBackground(Color.red);
button2.setFont(new java.awt.Font("Dialog", 0, 12));
button2.setForeground(Color.black);
button2.setLabel("确定");
label4.setFont(new java.awt.Font("Dialog", 0, 12));
label4.setForeground(Color.green);
label4.setText("网络地址:");
label5.setFont(new java.awt.Font("Dialog", 0, 12));
label5.setForeground(Color.yellow);
label5.setText("补充信息:");
label6.setEnabled(true);
label6.setFont(new java.awt.Font("Dialog", 0, 12));
label6.setForeground(Color.green);
label6.setText("所在领域:");
choice1.addItemListener(new Applet1_choice1_itemAdapter(this));
choice2.addItemListener(new Applet1_choice2_itemAdapter(this));
textArea1.setBackground(Color.cyan);
textArea1.setText("");
textArea1.addHierarchyBoundsListener(new Applet1_textArea1_hierarchyBoundsAdapter(this));
choice4.addItemListener(new Applet1_choice4_itemAdapter(this));
this.add(canvas1, new XYConstraints(213, 12, -1, -1));
this.add(button1, new XYConstraints(336, 9, 63, 19));
this.add(checkbox1, new XYConstraints(-1, 34, 190, -1));
this.add(checkbox2, new XYConstraints(-1, 58, 190, 25));
this.add(checkbox3, new XYConstraints(-1, 81, 190, 25));
this.add(choice2, new XYConstraints(254, 34, 79, 18));
this.add(button2, new XYConstraints(336, 34, 63, 19));
this.add(choice3, new XYConstraints(254, 59, 144, 18));
this.add(label5, new XYConstraints(2, 108, 61, 24));
this.add(choice4, new XYConstraints(60, 109, 338, 19));
this.add(label6, new XYConstraints(196, 80, -1, 26));
this.add(choice5, new XYConstraints(254, 83, 144, 18));
this.add(label2, new XYConstraints(196, 7, 50, 20));
this.add(label3, new XYConstraints(196, 30, -1, 26));
this.add(label4, new XYConstraints(196, 54, -1, 26));
this.add(choice6, new XYConstraints(38, 6, 151, 22));
this.add(choice1, new XYConstraints(243, 5, 90, 22));
this.add(label1, new XYConstraints(-2, 5, -1, 27));
this.add(textArea1, new XYConstraints(3, 133, 393, 165));
}
//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() {
String[][] pinfo =
{
{"param0", "String", ""},
};
return pinfo;
}
//Main method
public static void main(String[] args) {
Applet1 applet = new Applet1();
applet.isStandalone = true;
Frame frame;
frame = new Frame();
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);
}
void choice1_itemStateChanged(ItemEvent e) {
choice1.addItem("网络安全");
choice1.addItem("人工智能");
choice1.addItem("数据库技术");
choice1.addItem("计算机应用技术");
choice1.addItem("软件技术");
}
void choice2_itemStateChanged(ItemEvent e) {
choice2.addItem("北京");
choice2.addItem("武汉");
choice2.addItem("合肥");
choice2.addItem("西安");
choice2.addItem("上海");
choice2.addItem("天津");
choice2.addItem("长春");
choice2.addItem("广州");
choice2.addItem("郑州");
choice2.addItem("深圳");
choice2.addItem("哈尔滨");
choice2.addItem("大连");
button1.disable();
}
void choice4_itemStateChanged(ItemEvent e) {
}
void textArea1_ancestorMoved(HierarchyEvent e) {
textArea1.setText("");
textArea1.setForeground(Color.CYAN);
textArea1.append("输入焦点在choice1处");
}
void button1_actionPerformed(ActionEvent e) {
}
}
class Applet1_choice1_itemAdapter implements java.awt.event.ItemListener {
Applet1 adaptee;
Applet1_choice1_itemAdapter(Applet1 adaptee) {
this.adaptee = adaptee;
}
public void itemStateChanged(ItemEvent e) {
adaptee.choice1_itemStateChanged(e);
}
}
class Applet1_choice2_itemAdapter implements java.awt.event.ItemListener {
Applet1 adaptee;
Applet1_choice2_itemAdapter(Applet1 adaptee) {
this.adaptee = adaptee;
}
public void itemStateChanged(ItemEvent e) {
adaptee.choice2_itemStateChanged(e);
}
}
class Applet1_choice4_itemAdapter implements java.awt.event.ItemListener {
Applet1 adaptee;
Applet1_choice4_itemAdapter(Applet1 adaptee) {
this.adaptee = adaptee;
}
public void itemStateChanged(ItemEvent e) {
adaptee.choice4_itemStateChanged(e);
}
}
class Applet1_textArea1_hierarchyBoundsAdapter extends java.awt.event.HierarchyBoundsAdapter {
Applet1 adaptee;
Applet1_textArea1_hierarchyBoundsAdapter(Applet1 adaptee) {
this.adaptee = adaptee;
}
public void ancestorMoved(HierarchyEvent e) {
adaptee.textArea1_ancestorMoved(e);
}
}
class Applet1_button1_actionAdapter implements java.awt.event.ActionListener {
Applet1 adaptee;
Applet1_button1_actionAdapter(Applet1 adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.button1_actionPerformed(e);
}
}