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

📄 usearithmeticapplet.java~29~

📁 是用jbuilder实现的一些原代码程序
💻 JAVA~29~
字号:
package applettest;

import java.awt.*;
import java.awt.event.*;
import java.applet.*;

/**
 * <p>Title: </p>
 * <p>Description: </p>
 * <p>Copyright: Copyright (c) 2003</p>
 * <p>Company: </p>
 * @author not attributable
 * @version 1.0
 */

public class UseArithmeticApplet
    extends Applet {
  private boolean isStandalone = false;
  Label label1 = new Label();
  FlowLayout flowLayout1 = new FlowLayout();
  TextField textField1 = new TextField();
  TextField textField2 = new TextField();
  Button button1 = new Button();
  int a = 0, b = 1;
  //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 UseArithmeticApplet() {
  }

  //Initialize the applet
  public void init() {
    try {
      jbInit();
    }
    catch (Exception e) {
      e.printStackTrace();
    }
  }

  //Component initialization
  private void jbInit() throws Exception {
    label1.setText("请输入两个整型数据");
    this.setLayout(flowLayout1);
    textField1.setColumns(8);
    textField1.setSelectionStart(0);
    textField1.setText("");
    textField2.setCaretPosition(0);
    textField2.setColumns(10);
    textField2.setText("");
    button1.setLabel("计算");
    button1.addActionListener(new UseArithmeticApplet_button1_actionAdapter(this));
    this.add(label1, null);
    this.add(textField1, null);
    this.add(textField2, null);
    this.add(button1, null);
  }

  //Get Applet information
  public String getAppletInfo() {
    return "Applet Information";
  }

  //Get parameter info
  public String[][] getParameterInfo() {
    return null;
  }

  public void paint(Graphics g) {
    g.drawString(a + "+" + b + "=" + (a + b), 10, 50);
    g.drawString(a + "-" + b + "=" + (a - b), 10, 70);
    g.drawString(a + "*" + b + "=" + (a * b), 10, 90);
    g.drawString(a + "/" + b + "=" + (a / b), 10, 110);
    g.drawString(a + "%" + b + "=" + (a % b), 10, 130);
  }

  void button1_actionPerformed(ActionEvent e) {
    a = Integer.parseInt(textField1.getText());
    b = Integer.parseInt(textField2.getText());
    repaint();
  }
}

class UseArithmeticApplet_button1_actionAdapter
    implements java.awt.event.ActionListener {
  UseArithmeticApplet adaptee;

  UseArithmeticApplet_button1_actionAdapter(UseArithmeticApplet adaptee) {
    this.adaptee = adaptee;
  }

  public void actionPerformed(ActionEvent e) {
    adaptee.button1_actionPerformed(e);
  }
}

⌨️ 快捷键说明

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