Java 如何从动作侦听器计算值
我正在用GUI构建一个程序,并试图让程序计算驱动程序是否超过或低于限制。我使用一个动作监听器来读取用户要输入的内容Java 如何从动作侦听器计算值,java,if-statement,event-handling,actionlistener,Java,If Statement,Event Handling,Actionlistener,我正在用GUI构建一个程序,并试图让程序计算驱动程序是否超过或低于限制。我使用一个动作监听器来读取用户要输入的内容 public void calculation() { if(txtSpeed > txtLimit){ System.out.println("The dirver is over the limit"); } else{ System.out.println("The driver is under the li
public void calculation() {
if(txtSpeed > txtLimit){
System.out.println("The dirver is over the limit");
}
else{
System.out.println("The driver is under the limit");
}
class VhLimitHandler implements ActionListener{
public void actionPerformed(ActionEvent event){
txtLimit = Double.parseDouble(textLimit.getText());
}
}
class VhSpeedHandler implements ActionListener{
public void actionPerformed(ActionEvent event){
txtSpeed = Double.parseDouble(textSpeed.getText());
问题是什么?当我试图运行程序时,在我输入值之前,系统就会出现