Java 给了我公共布尔操作的错误:缺少返回语句。我该如何解决?
该程序创建 3 个按钮 Yes、No、Maybe。
import java.awt.*;
import java.applet.*;
public class ButtonDemo extends Applet {
String msg = "Ti piace Java?";
public void init() {
Button yes = new Button("Si");
Button no = new Button("No");
Button maybe = new Button("Non so");
setBackground(Color.white);
add(yes);
add(no);
add(maybe);
}
public void paint(Graphics g) {
g.drawString(msg,6,100);
}
public boolean action(Event evtObj,
Object arg) {
if (evtObj.target instanceof Button) {
if (arg.equals("Si")) {
setBackground(Color.green);
msg = "I love Java!";
}
if (arg.equals("No")) {
setBackground(Color.red);
msg = "Io odio Java!";
}
if (arg.equals("Non so")) {
setBackground(Color.yellow);
msg = "Non me ne importa niente!";
}
}
}
}
慕侠2389804
料青山看我应如是
慕村225694
相关分类