⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 goodeveningapplet.java

📁 金旭亮的java教案
💻 JAVA
字号:
package firstapplet;import java.awt.*;import java.awt.event.*;import java.applet.*;import javax.swing.UIManager;/** * <p>Title: </p> * <p>Description: </p> * <p>Copyright: Copyright (c) 2004</p> * <p>Company: </p> * @author not attributable * @version 1.0 */public class GoodEveningApplet extends Applet {  private boolean isStandalone = false;  BorderLayout borderLayout1 = new BorderLayout();  Panel upper = new Panel();  Panel lower = new Panel();  CardLayout cardLayout1 = new CardLayout();  Panel panel1 = new Panel();  Panel panel2 = new Panel();  Label label1 = new Label();  BorderLayout borderLayout2 = new BorderLayout();  BorderLayout borderLayout3 = new BorderLayout();  Label label2 = new Label();  Choice choice1 = new Choice();  Label label3 = new Label();  //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 GoodEveningApplet() {  }  //Initialize the applet  public void init() {    try {      choice1.addItem("English");    choice1.addItem("Chinese");      jbInit();    }    catch(Exception e) {      e.printStackTrace();    }  }  //Component initialization  private void jbInit() throws Exception {    this.setLayout(borderLayout1);    upper.setBackground(Color.orange);    lower.setBackground(Color.magenta);    lower.setForeground(Color.black);    lower.setLayout(cardLayout1);    panel2.setBackground(UIManager.getColor("ToolTip.background"));    panel2.setForeground(Color.black);    panel2.setLayout(borderLayout3);    panel1.setBackground(Color.cyan);    panel1.setForeground(Color.black);    panel1.setLayout(borderLayout2);    label1.setFont(new java.awt.Font("Dialog", 1, 30));    label1.setText("         Good Evening");    label2.setFont(new java.awt.Font("Dialog", 1, 30));    label2.setText("               晚上好");    label3.setFont(new java.awt.Font("Dialog", 0, 15));    label3.setText("Select a language");    choice1.addItemListener(new GoodEveningApplet_choice1_itemAdapter(this));    this.add(upper,  BorderLayout.NORTH);    upper.add(label3, null);    upper.add(choice1, null);    this.add(lower, BorderLayout.CENTER);    lower.add(panel1, "panel1");    panel1.add(label1,  BorderLayout.CENTER);    lower.add(panel2,  "panel2");    panel2.add(label2, BorderLayout.CENTER);  }  //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() {    return null;  }  void choice1_itemStateChanged(ItemEvent e) {    if ("English".equals(choice1.getSelectedItem())){          cardLayout1.show(lower, "panel1");        }        else if ("Chinese".equals(choice1.getSelectedItem())){          cardLayout1.show(lower, "panel2");        }  }}class GoodEveningApplet_choice1_itemAdapter implements java.awt.event.ItemListener {  GoodEveningApplet adaptee;  GoodEveningApplet_choice1_itemAdapter(GoodEveningApplet adaptee) {    this.adaptee = adaptee;  }  public void itemStateChanged(ItemEvent e) {    adaptee.choice1_itemStateChanged(e);  }}

⌨️ 快捷键说明

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