applettest.java

来自「东软JAVA内部资料」· Java 代码 · 共 90 行

JAVA
90
字号
package org.course.gui;import java.awt.*;import java.awt.event.*;import java.applet.*;import javax.swing.*;/** * <p>Title: </p> * <p>Description: </p> * <p>Copyright: Copyright (c) 2003</p> * <p>Company: </p> * @author not attributable * @version 1.0 */public class AppletTest extends Applet {  private boolean isStandalone = false;  BorderLayout borderLayout1 = new BorderLayout();  Label label1 = new Label();  TextArea textArea1 = new TextArea();  Panel panel1 = new Panel();  Button button1 = new Button();  Button button2 = 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 AppletTest() {  }  //Initialize the applet  public void init() {    try {      jbInit();    }    catch(Exception e) {      e.printStackTrace();    }  }  //Component initialization  private void jbInit() throws Exception {    label1.setAlignment(Label.CENTER);    label1.setLocale(java.util.Locale.getDefault());    label1.setText("这是一个Applet");    this.setLayout(borderLayout1);    textArea1.setText("在这里输入");    button1.setLabel("确定");    button1.addActionListener(new AppletTest_button1_actionAdapter(this));    button2.setLabel("取消");    this.add(label1, BorderLayout.NORTH);    this.add(textArea1, BorderLayout.CENTER);    this.add(panel1,  BorderLayout.SOUTH);    panel1.add(button1, null);    panel1.add(button2, null);  }  //Get Applet information  public String getAppletInfo() {    return "Applet Information";  }  //Get parameter info  public String[][] getParameterInfo() {    return null;  }  void button1_actionPerformed(ActionEvent e) {    String hello=textArea1.getText();    JOptionPane.showMessageDialog(this,hello,"Applet提示",0);    System.out.println(hello);  }}class AppletTest_button1_actionAdapter implements java.awt.event.ActionListener {  AppletTest adaptee;  AppletTest_button1_actionAdapter(AppletTest adaptee) {    this.adaptee = adaptee;  }  public void actionPerformed(ActionEvent e) {    adaptee.button1_actionPerformed(e);  }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?