首页 扫雷java代码

扫雷java代码

举报
开通vip

扫雷java代码扫雷java代码 /** * This program is written by Jerry Shen(Shen Ji Feng) * use the technology of SWING GUI and the OO design * * @author Jerry Shen(jerry.shen@cognizant.com) * Distributed under the licience of GPLv3 * all rights reserved. */ import java.awt...

扫雷java代码
扫雷java代码 /** * This program is written by Jerry Shen(Shen Ji Feng) * use the technology of SWING GUI and the OO design * * @author Jerry Shen(jerry.shen@cognizant.com) * Distributed under the licience of GPLv3 * all rights reserved. */ import java.awt.*; import javax.swing.*; //图形计数器JCounter三位 class JCounter extends JPanel { private ImageIcon [] numSet = { new ImageIcon("c0.gif"), new ImageIcon("c1.gif"), new ImageIcon("c2.gif"), new ImageIcon("c3.gif"), new ImageIcon("c4.gif"), new ImageIcon("c5.gif"), new ImageIcon("c6.gif"), new ImageIcon("c7.gif"), new ImageIcon("c8.gif"), new ImageIcon("c9.gif"), }; private JButton [] counter = { new JButton(numSet[0]), new JButton(numSet[0]), new JButton(numSet[0])}; private int counterNum; private Insets space; public JCounter() { this(0); } public JCounter(int num) { super(); setSize(23, 39); space = new Insets(0,0,0,0); this.counterNum = num; for (int i=0; i< 3; i++){ counter[i].setSize(13,23); counter[i].setMargin(space); add(counter[i]); } this.setVisible(true); resetImage(); } public int getCounterNum() { return(counterNum); } private void setCounterNum(int num){ this.counterNum = num; } private void resetImage() { int ones, tens, hundreds; ones = counterNum % 10 ; tens = counterNum % 100/10; hundreds = (counterNum) % 1000/100; this.counter[0].setIcon(numSet[hundreds]); this.counter[1].setIcon(numSet[tens]); this.counter[2].setIcon(numSet[ones]); } public void resetCounter(int num) { setCounterNum(num); resetImage(); this.repaint(); } public static void main(String[] args) { JFrame jf = new JFrame("Test"); jf.setSize(23,39); JCounter jc = new JCounter(); jf.setContentPane(jc); jf.show(); jc.resetCounter(394); } }
本文档为【扫雷java代码】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
该文档来自用户分享,如有侵权行为请发邮件ishare@vip.sina.com联系网站客服,我们会及时删除。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。
本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。
网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。
下载需要: 免费 已有0 人下载
最新资料
资料动态
专题动态
is_531654
暂无简介~
格式:doc
大小:15KB
软件:Word
页数:3
分类:工学
上传时间:2017-10-06
浏览量:48