import java.awt.*;
import java.applet.*;
import java.awt.event.*;
public class ButtonDemo extends Applet implements ActionListener {
Label lb;
String msg="";
public void init(){
lb=new Label("a梦你是否是垃圾中的战斗机?");
add(lb);
Button yes=new Button("是");
Button no=new Button("否");
Button maybe=new Button("取消");
add(yes);
add(no);
add(maybe);
yes.addActionListener(this);
no.addActionListener(this);
maybe.addActionListener(this);
}
public void actionPerformed(ActionEvent e){
String str=e.getActionCommand();
if(str=="是"){
msg="你很诚实";
}
else if(str=="否"){
msg="你在欺骗自己";
}
else{
msg="不要逃避现实!";
}
repaint();
}
public void paint(Graphics g){
g.drawString(msg,6,100);
}
}
了解a梦
最新推荐文章于 2021-06-01 14:48:52 发布