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

📄 handlesin.java

📁 书上的例子
💻 JAVA
字号:
import java.util.LinkedList;
import javax.swing.*;
import java.awt.event.*;

public class HandleSin implements ActionListener {
    LinkedList<String> list;
    JTextField resultShow, showComputerProcess;
    JTextArea saveComputerProcess;

    HandleSin(LinkedList<String> list, JTextField t1, JTextField t2, JTextArea t3) {
        this.list = list;
        resultShow = t1;
        showComputerProcess = t2;
        saveComputerProcess = t3;
    }

    public void actionPerformed(ActionEvent e) {
        if (list.size() == 1 || list.size() == 2) {
            String numOne = list.getFirst();
            try {
                double x = Double.parseDouble(numOne);
                double result = Math.sin(x);
                String str = String.valueOf(result);
                list.set(0, str);
                resultShow.setText(str);
                String process = "sin(" + numOne + ") = " + result;
                showComputerProcess.setText(process);
                saveComputerProcess.append(" " + process + "\n");
                if (list.size() == 2)
                    list.removeLast();
            } catch (Exception ex) {}
        } else if (list.size() == 3) {
            String numTwo = list.getLast();
            try {
                double x = Double.parseDouble(numTwo);
                double result = Math.sin(x);
                String str = String.valueOf(result);
                list.set(0, str);
                resultShow.setText(str);
                String process = "sin(" + numTwo + ") = " + result;
                showComputerProcess.setText(process);
                saveComputerProcess.append(" " + process + "\n");
                list.removeLast();
                list.removeLast();
            } catch (Exception ex) {}
        }
    }
}

⌨️ 快捷键说明

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