So I am trying to make a calculator and I am using JFrame code and trying to use the built in Math to find the square root of a number. The code below is where I am having issues. "display.setText(Math.sqrt(Double.parseDouble(display.getText())));"
gives me the error of "The method setText(String) in the type JTextComponent is not applicable for the arguments (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);