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

📄 handleback.java

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

public class HandleBack implements ActionListener {
    LinkedList<String> list;
    JTextField resultShow, showComputerProcess;

    HandleBack(LinkedList<String> list, JTextField t1, JTextField t2) {
        this.list = list;
        resultShow = t1;
        showComputerProcess = t2;
    }

    public void actionPerformed(ActionEvent e) {
        if (list.size() == 1) {
            String num = (String)list.getFirst();
            if (num.length() >= 1) {
                num = num.substring(0, num.length() - 1);
                list.set(0, num);
                resultShow.setText(num);
                showComputerProcess.setText("" + num);
            } else {
                list.removeLast();
                resultShow.setText("0");
                showComputerProcess.setText("0");
            }
        } else if (list.size() == 3) {
            String num = (String)list.getLast();
            if (num.length() >= 1) {
                num = num.substring(0, num.length() - 1);
                list.set(2, num);
                resultShow.setText(num);
                showComputerProcess.setText(num);
            } else {
                list.removeLast();
                resultShow.setText("0");
                showComputerProcess.setText("0");
            }
        }
    }
}

⌨️ 快捷键说明

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