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

📄 multiplier.java

📁 由于想一次上传成功 所以将二个教程打包成了一个 这些例子几乎包含了所有java的框架集合
💻 JAVA
字号:
import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;

/*
  <APPLET
     CODE=multiplier.class
     WIDTH=200
     HEIGHT=200 >
   </APPLET>
*/

public class multiplier extends Applet implements ActionListener {

    TextField text1, text2, answertext;
    Label multiplylabel;
    Button button1;

    public void init()
    {
        text1 = new TextField(10);
        add(text1);

        multiplylabel = new Label("*");
        add(multiplylabel);

        text2 = new TextField(10);
        add(text2);

        button1 = new Button("=");
        add(button1);
        button1.addActionListener(this); 
                     
        answertext = new TextField(10);
        add(answertext);
    }

    public void actionPerformed(ActionEvent e) {
        if(e.getSource() == button1){
            //int sum = Integer.parseInt(text1.getText()) + Integer.parseInt(text2.getText());
            //answertext.setText(String.valueOf(sum));
            int product = Integer.parseInt(text1.getText()) * Integer.parseInt(text2.getText());
            answertext.setText(String.valueOf(product));
        }
    }

}

⌨️ 快捷键说明

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