我对图形用户界面比较陌生,我创建了一个实现基本计算器功能的界面。这些方法包括:add(),subtract(),multiply()和divide()。我在我的actionPerformed方法中收到错误,它说“类型Operate中的方法add(int,int)不适用于参数(int)。”我尝试了包括我传入我的公共类Operate的变量,但仍然收到此错误。我该如何解决这个问题?Java - 处理监听器
这里是我这个方法的代码:
JButton btnNewButton_10 = new JButton("+");
btnNewButton_10.setFont(new Font("Helvetica Neue", Font.PLAIN, 15));
btnNewButton_10.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
int myFunction = calculate.add(Integer.parseInt(textDisplay.getText())); // The error is specifically underlining the keyword "add"
textDisplay.setText("");
以及它有点明显...它强调'add',你只能把一个号码! – Doorknob