这是一个java程序,有两个按钮用于更改整数值并显示它.但是在IntelliJIDEA中有两行
increase.addActionListener(incListener());
decrease.addActionListener(decListener());
Run Code Online (Sandbox Code Playgroud)
继续显示错误'预期方法调用'.
我不知道该怎么做才能解决这个问题.
任何帮助将不胜感激
谢谢
注意:完整代码附在下面.
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class Main extends JDialog {
public JPanel contentPane;
public JButton decrease;
public JButton increase;
public JLabel label;
public int number;
public Main() {
setContentPane(contentPane);
setModal(true);
increase = new JButton();
decrease = new JButton();
increase.addActionListener(incListener());
decrease.addActionListener(decListener());
number = 50;
label = new JLabel();
}
public class incListener implements ActionListener {
public void actionPerformed (ActionEvent event) {
number++;
label.setText("" + number);
}
}
public class decListener implements …Run Code Online (Sandbox Code Playgroud) 我收到了以下问题.
String string1 = "The ice cold ice-cream";
String string2 = "phone";
String string3 = "";
int p = string1.indexOf("ice",8);
string3 = string1.substring(0, p + 1);
string3 = string3 + string2.toUpperCase();
Run Code Online (Sandbox Code Playgroud)
我似乎无法获得第二和第三的价值.
子串,int p真让我困惑.
任何人都可以帮助解决问题并解释如何解决这个问题.
谢谢.