JAVA抽奖系统源代码_第1页
JAVA抽奖系统源代码_第2页
JAVA抽奖系统源代码_第3页
JAVA抽奖系统源代码_第4页
JAVA抽奖系统源代码_第5页
已阅读5页,还剩10页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

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. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论