java猜数字小程序,看不懂 ,能不能帮写个注释啊?

publicclassGussNumberextendsFrame{privatestaticGussNumbermainFrame=newGussNumber();pr... public class GussNumber extends Frame{
private static GussNumber mainFrame = new GussNumber();
private static Button yes = new Button("确定输入");
private static Button reTry = new Button("重新测试");
private static Label lb = new Label("请输入你猜测的数字(0~100):");
private static Label ts = new Label("欢迎使用......");
private static Double r_num = new Double(Math.random()*100);
private static Integer num = new Integer(r_num.intValue());
private static int t_num;
private static TextField tf = new TextField("",5);

public GussNumber(){
addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
dispose();
System.exit(0);
}
});
}
public static void main (String[] args) {

yes.addActionListener(new ButtonListener());
reTry.addActionListener(new ButtonListener());
System.out.println("Starting GussNumber...");
mainFrame.setBackground(Color.WHITE);
mainFrame.setSize(400,200);
mainFrame.setLayout(null);
mainFrame.setLocationRelativeTo(null);
mainFrame.setTitle("猜数字");
mainFrame.add(lb);
lb.setBounds(70,150,200,20);
mainFrame.add(tf);
tf.setBounds(270,150,50,20);
mainFrame.add(yes);
yes.setBounds(240,170,60,25);
mainFrame.add(ts);
ts.setBounds(70,130,200,20);
mainFrame.add(reTry);
reTry.setBounds(100,170,60,25);
mainFrame.setResizable(false);
mainFrame.setVisible(true);
}
static class ButtonListener implements ActionListener {
public void actionPerformed(ActionEvent event) {
if(event.getSource()==yes){
try{
t_num = Integer.parseInt(tf.getText());
}catch(NumberFormatException e){
Graphics g = mainFrame.getGraphics();
ts.setText("请输入正常的数字!");
}
if(t_num == num){
ts.setText("答对啦! 恭喜你~");
Graphics g = mainFrame.getGraphics();
}
if(t_num > num){
ts.setText("大了点哦! 继续努力~");
Graphics g = mainFrame.getGraphics();
}
if(t_num < num){
ts.setText("试试换个大点的数字~");
Graphics g = mainFrame.getGraphics();
}
}
if(event.getSource()==reTry){
Image img = mainFrame.getToolkit().getImage("welcome.jpg");
Graphics g = mainFrame.getGraphics();
g.drawImage(img,100,30,mainFrame);
r_num = new Double(Math.random()*100);
num = new Integer(r_num.intValue());
tf.setText("");
}
}
}
}
展开
 我来答
乁Freedom
2010-06-15 · TA获得超过2128个赞
知道小有建树答主
回答量:1580
采纳率:0%
帮助的人:1403万
展开全部
注释到一半不想注释了
代码太难看
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式