




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、/* 主界面* MainFrame.java* Created on _DATETIME*/* author _USER*/* Creates new form MainFrame */super(parent, modal);initComponents();this.setLocationRelativeTo(null);/ 居中显示 tryUIManager.setLookAndFeel(new SubstanceLookAndFeel();JFrame.setDefaultLookAndFeelDecorated(true);JDialog.setDefaultLookAndFeelD
2、ecorated(true);SubstanceLookAndFeel.setCurrentTheme(new SubstanceTerracottaTheme();/SubstanceLookAndFeel.setSkin(new EmeraldDuskSkin();/SubstanceLookAndFeel.setCurrentButtonShaper(new /ClassicButtonShaper();/SubstanceLookAndFeel.setCurrentWatermark(new/SubstanceBubblesWatermark();/SubstanceLookAndFe
3、el.setCurrentBorderPainter(new/ StandardBorderPainter();/ SubstanceLookAndFeel.setCurrentGradientPainter(new/StandardGradientPainter();/ 水晶蓝/SubstanceLookAndFeel.setCurrentTitlePainter(new FlatTitlePainter(); catch (Exception e) try showPerson(); catch (IOException e) / TODO Auto-generated catch blo
4、cke.printStackTrace();public void showPerson() throws IOException/com/insigma/config/name.txt).getPath();FileInputStream fileInputStream = new FileInputStream(filename);InputStreamReader inputStreamReader = new InputStreamReader( fileInputStream, gbk);BufferedReader bufferedReader = new BufferedRead
5、er(inputStreamReader);String name = ;String bufname = ;int key = 1;while (name = bufferedReader.readLine() != null)if (bufname.equals()bufname = name;elsebufname = bufname + n + name;key+;/* This method is called from within the constructor toinitialize the form.WARNING: Do NOT modify this code. The
6、 content of this method isalways regenerated by the Form Editor.*/GEN-BEGIN:initComponents/ private void initComponents()setTitle(u516cu53f8u5e74u7ec8u62bdu5956u7cfbu7edf);jLabel1.setText(u4e00u7b49u5956u83b7u5f97u8005uff1a);jLabel2.setText(u4e8cu7b49u5956u83b7u5f97u8005uff1a);jLabel3.setText(u4e09u
7、7b49u5956u83b7u5f97u8005uff1a);jTextArea1.setColumns(20);jTextArea1.setRows(5);jScrollPane1.setViewportView(jTextArea1);jTextArea2.setColumns(20);jTextArea2.setRows(5);jScrollPane2.setViewportView(jTextArea2);jTextArea3.setColumns(20);jTextArea3.setRows(5);jScrollPane3.setViewportView(jTextArea3);jL
8、abel5.setText(u62bdu5956u8005u540du5355uff1a);jTextArea4.setColumns(20);jTextArea4.setRows(5);jScrollPane4.setViewportView(jTextArea4);jButton1.setText(u5f00u59cb);jButton1ActionPerformed(evt););jButton2.setText(u6682u505c);jButton2.setEnabled(false);jButton2ActionPerformed(evt););jButton3.setText(u
9、91cdu7f6e);jButton3.setEnabled(false);jButton3ActionPerformed(evt););jLabel6.setText(u516cu53f8u5e74u7ec8u62bdu5956);getContentPane();getContentPane().setLayout(layout);layout.setHorizontalGroup(layout.addGroup(layout.createSequentialGroup().addGroup(layout.createParallelGroup(.addGroup(layout.creat
10、eSequentialGroup().addGap(98, 98,98).addComponent(jButton1).addGap(47, 47,47) .addComponent(jButton3).addGap(44, 44,44) .addComponent(jButton2)104, 104).addGroup(layout.createSequentialGroup() .addContainerGap() .addGroup(layout.createParallelGroup(.addGroup(layout.createSequentialGroup().addGroup(l
11、ayout.createParallelGroup(.addComponent(jScrollPane1,142,.addComponent(jLabel1).addPreferredGap(14,Short.MAX_VALUE).addGroup(layout.createParallelGroup(.addComponent(jLabel2).addComponent(jScrollPane2,137,.addGap(33,33,33).addGroup(layout.createParallelGroup(.addComponent(jScrollPane3,126,.addCompon
12、ent(jLabel3).addGroup(layout.createSequentialGroup().addGap(108,108,108).addComponent(jLabel6).addComponent(jLabel5).addGroup( layout.createSequentialGroup()jScrollPane4,134,.addPreferredGap(80,Short.MAX_VALUE).addComponent(jLabel4,116,.addGap(122,122,122).addPreferredGap(.addGap(13, 13, 13);layout.
13、setVerticalGroup(layout.addGroup(layout.createSequentialGroup().addComponent(jLabel6).addGap(26, 26, 26).addGroup(layout.createParallelGroup(.addGroup(layout.createSequentialGroup().addComponent(jLabel1) .addPreferredGap( .addComponent(jScrollPane1,.addGroup(layout.createSequentialGroup().addGroup(l
14、ayout.createParallelGroup(jLabel3).addComponent(jLabel2).addPreferredGap(.addGroup(layout.createParallelGroup(.addComponent(jScrollPane3,.addComponent(jScrollPane2,.addGap(28, 28, 28).addComponent(jLabel5).addPreferredGap(.addGroup(layout.createParallelGroup(.addComponent(jLabel4,148, Short.MAX_VALU
15、E).addComponent(jScrollPane4,148, Short.MAX_VALUE).addPreferredGap(.addGroup(layout.createParallelGroup(.addComponent(jButton1).addGroup(layout.createParallelGroup(.addComponent(jButton3).addComponent(jButton2).addContainerGap();pack();/ /GEN-END:initComponents/* 重置事件* param evt*/CommUtil.boo = fals
16、e;/重置计数器CommUtil.firstsum = 0;CommUtil.secondsum = 0;CommUtil.thirdsum = 0;/清空抽奖框/重置人员 try showPerson(); catch (IOException e) / TODO Auto-generated catch block e.printStackTrace();/*暂停事件param evt*/CommUtil.boo = false;/*开始事件param evt*/CommUtil.boo = true;CardThread cardthread = new CardThread(this)
17、;cardthread.start();ImageThread imageThread = new ImageThread(this);imageThread.start();new Thread(cardthread).start();new Thread(cardthread).start();new Thread(cardthread).start();new Thread(cardthread).start();/* param args the command line arguments*/public static void main(String args) public vo
18、id run()System.exit(0););dialog.setVisible(true););/GEN-BEGIN:variables/ Variables declaration - do not modify/ End of variables declaration/GEN-END:variables 抽奖功能:public class CardThread extends Thread private MainFrame mainframe;public CardThread(MainFrame mainframe) this.mainframe = mainframe;pub
19、lic void run()synchronized (mainframe)firstCard();secondCard();thirdCard();if (CommUtil.isEnd()/* 抽一等奖*/public void firstCard() while (CommUtil.boo & CommUtil.firstsum CommUtil.firstcount) int key = (int) (Math.random() * 60 + 1);if (CommUtil.getPerson(key)+ n + name); elseCommUtil.deletePerson(key)
20、;String bufname = CommUtil.mapToString();CommUtil.firstsum+;trysleep(1000); catch (InterruptedException e)/ TODO Auto-generated catch block e.printStackTrace();/*抽三等奖*/public void thirdCard()while (CommUtil.boo & CommUtil.thirdsum CommUtil.thirdcount) int key = (int) (Math.random() * 60 + 1);if (Com
21、mUtil.getPerson(key)+ n + name); elseCommUtil.deletePerson(key);String bufname = CommUtil.mapToString();CommUtil.thirdsum+;trysleep(1000); catch (InterruptedException e) / TODO Auto-generated catch block e.printStackTrace();/* 抽二等奖*/public void secondCard()while (CommUtil.boo & CommUtil.secondsum Co
22、mmUtil.secondcount) int key = (int) (Math.random() * 60 + 1);if (CommUtil.getPerson(key)+ n + name); elseCommUtil.deletePerson(key);String bufname = CommUtil.mapToString();CommUtil.secondsum+;trysleep(1000); catch (InterruptedException e)/ TODO Auto-generated catch block e.printStackTrace();工具类:publ
23、ic class CommUtilpublic static boolean boo = false;public static Map map = new HashMap();/* 奖项获奖人数*/public static int firstcount = 1;public static int secondcount = 3;public static int thirdcount = 5; /* 计数器*/public static int firstsum = 0;public static int secondsum = 0;public static int thirdsum =
24、 0;/* 查找人员*/public static boolean getPerson(int key) boolean boo = false;if(map.get(key)!=null & !map.get(key).equals() boo = true; return boo;public static boolean isEnd()boolean boo = false;if(firstcount = firstsum & secondcount=secondsum & thirdcount=thirdsum) boo = true;return boo;/*删除人员*/public static boolean deletePerson(int key)boolean boo = false; m
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 不会被跳墙的居间合同
- 售后服务协议合同
- 公司股份转让合同协议书详细
- 技术服务合同免税
- 墙布供货施工合同协议书
- 股权分配及股份制公司合同详解
- 产品销售与分销合同细节规定
- 汽车零部件生产技术优化合同
- 广东工贸职业技术学院《工程材料及制造基础双语》2023-2024学年第二学期期末试卷
- 兰州航空职业技术学院《中学英语教学设计》2023-2024学年第二学期期末试卷
- GB 19522-2004车辆驾驶人员血液、呼气酒精含量阈值与检验
- 登记总账、账务处理程序课件
- 热能与动力工程测试技术(白)课件
- 彩生活运营模式2016年
- 脂肪肝的科普课件
- 某银行安全保卫工作知识考试参考题库(500题)
- 片剂工艺流程图
- 企业服务工作实施方案
- 信息技术ppt课件完整版
- 新湘教(湖南美术)版小学美术五年级下册全册PPT课件(精心整理汇编)
- 大智慧指标公式函数大全(完整可打印版)
评论
0/150
提交评论