Java开发网 Java开发网
注册 | 登录 | 帮助 | 搜索 | 排行榜 | 发帖统计  

您没有登录

» Java开发网 » Java SE 综合讨论区 » 编程/算法/API  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
flat modethreaded modego to previous topicgo to next topicgo to back
作者 Re:求助一题 [Re:xxyxq163]
hubmygirl





发贴: 7
积分: 0
于 2007-09-12 00:12 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
package tarema.com.cn;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.applet.Applet;

public class Test_Awt extends JApplet implements ActionListener {

  int m = 0, n = 0, inputNumber, value;

  JLabel inputLabel;
  JTextField inputField;
  JButton beginButton;

  private boolean flag = false;

  public void init() {
    Container container = getContentPane();
    container.setLayout(new FlowLayout());

    inputLabel = new JLabel("Enter a key ");
    container.add(inputLabel);

    inputField = new JTextField(10);

    container.add(inputField);
    beginButton = new JButton("Begin");
    container.add(beginButton);
    
    
    beginButton.addActionListener(this);
    
  }

  public void actionPerformed(ActionEvent e) {

    //    if ( e.getActionCommand().equals())
//    System.out.println ( e.getActionCommand() );
    if ( inputField.getText().equals("")&& flag == false ){
      flag = true ;
      value = product();
      displayMessage();
      return ;
    }  
    
//    System.out.println ( value );
    
    inputNumber = Integer.parseInt(inputField.getText());
    System.out.println ( inputNumber );
    
    if (value == inputNumber){
      flag = false;
      inputField.setText("");
      showStatus("good");
    }
    else{
      showStatus("Try again");
      inputField.setText("");
      flag = false;
    }
  }

  public int product() {
    m = 1 + (int) (Math.random() * 9);
    n = 1 + (int) (Math.random() * 9);
    return m * n;
  }

  public void displayMessage() {
    showStatus(m + " * " + n + " = ?");
  }
  public static void main ( String [] args) {
    new Test_Awt().init();
  }
}
//呵呵 ,你看看,你的程序会有异常,最简单的方法就是跳过此异常, 在出现之前返回!




Hibernate的优点

话题树型展开
人气 标题 作者 字数 发贴时间
9190 求助一题 xxyxq163 1385 2007-07-26 19:50
6782 Re:求助一题 hubmygirl 1670 2007-09-12 00:12
6845 Re:求助一题 JiafanZhou 125 2007-11-11 08:11
6545 Re:求助一题 long_5281 2733 2007-11-09 09:54

flat modethreaded modego to previous topicgo to next topicgo to back
  已读帖子
  新的帖子
  被删除的帖子
Jump to the top of page

   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923