所以我正在尝试制作一个计算器,我正在使用 JFrame 代码并尝试使用内置的 Math 来查找数字的平方根。下面的代码是我遇到问题的地方。“display.setText(Math.sqrt(Double.parseDouble(display.getText())));”
给我“JTextComponent 类型中的方法 setText(String) 不适用于参数 (double)”的错误
sqrt = new JButton("SQRT");
sqrt.setBounds(298, 141, 65, 65);
sqrt.setBackground(Color.BLACK);
sqrt.setForeground(Color.BLACK);
sqrt.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
setTempFirst(Double.parseDouble(display.getText()));
display.setText(Math.sqrt(Double.parseDouble(display.getText())));
operation[5] = true;
}
});
add(sqrt);