简单猜数字界面版源码

简单猜数字界面版源码

ID:38718923

大小:62.50 KB

页数:9页

时间:2019-06-18

简单猜数字界面版源码_第1页
简单猜数字界面版源码_第2页
简单猜数字界面版源码_第3页
简单猜数字界面版源码_第4页
简单猜数字界面版源码_第5页
资源描述:

《简单猜数字界面版源码》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库

1、packagecom.game.caishuzi;importjava.awt.Button;importjava.awt.Color;importjava.awt.event.ActionEvent;importjava.awt.event.ActionListener;importjava.util.Random;importjava.util.Scanner;importjava.util.Timer;importjava.util.TimerTask;importjavax.swing.JFrame;importjavax.swing.JLabel;importjav

2、ax.swing.JOptionPane;importjavax.swing.JTextField;publicclassWindowextendsJFrame{/****/privatestaticfinallongserialVersionUID=1L;privatestaticint[]num;privatestaticStringouttime;privatestaticbooleanwaits=false;//false暂停true继续publicstaticvoidmain(String[]args){JFramejf=newJFrame();jf.setTitl

3、e("猜数字");jf.setLayout(null);setButtoms(jf);jf.setSize(400,300);jf.setLocationRelativeTo(null);jf.setResizable(false);jf.setVisible(true);jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);}publicstaticvoidsetLables(JFramejf){JLabeljl=newJLabel("级别:");JLabelsumtime=newJLabel("倒计时:");jl.setBou

4、nds(80,70,40,30);sumtime.setBounds(20,230,55,30);jf.add(jl);jf.add(sumtime);}publicstaticvoidsetButtoms(finalJFramejf){Buttonbt0=newButton("简单");Buttonbt1=newButton("普通");Buttonbt2=newButton("困难");Buttonbt3=newButton("我猜");Buttonbt4=newButton("答案");Buttonstart=newButton("开始");finalButtonsto

5、p=newButton("暂停");Buttonbt=newButton("退出");finalJLabeljtf=newJLabel("普通");//级别显示finalJLabelmessages=newJLabel();//级别结果信息finalJTextFieldshuru=newJTextField("请输入5个不重复的数字!");//输入框shuru.setEnabled(false);//没有点击开始前,不能输入,只读设置//秒表,倒计时finalJLabeltime=newJLabel("10:00");bt0.setBackground(Color.gray)

6、;bt1.setBackground(Color.gray);bt2.setBackground(Color.gray);bt0.setBounds(80,20,50,30);bt1.setBounds(170,20,50,30);bt2.setBounds(260,20,50,30);bt3.setBounds(230,120,50,30);bt4.setBounds(300,120,50,30);bt.setBounds(320,220,50,30);start.setBounds(230,70,50,30);stop.setBounds(300,70,50,30);jt

7、f.setBounds(130,70,50,30);shuru.setBounds(80,120,140,30);messages.setBounds(10,150,280,30);time.setBounds(70,230,150,30);//按钮事件start//1.选择难度bt0.addActionListener(newActionListener(){@OverridepublicvoidactionPerformed(ActionEvente){jtf.setText("简单");shuru

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。