国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 學(xué)院 > 開(kāi)發(fā)設(shè)計(jì) > 正文

java 掃雷游戲源碼案例項(xiàng)目

2019-11-14 22:51:48
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友
java 掃雷游戲源碼案例項(xiàng)目

代碼如下

import java.awt.*;import javax.swing.*;//圖形計(jì)數(shù)器JCounter三位class JCounter extends JPanel {        PRivate static final long serialVersionUID = 1L;        private ImageIcon [] numSet = { new ImageIcon("image/c0.gif"), new ImageIcon("image/c1.gif"),                                             new ImageIcon("image/c2.gif"), new ImageIcon("image/c3.gif"),                                             new ImageIcon("image/c4.gif"), new ImageIcon("image/c5.gif"),                                             new ImageIcon("image/c6.gif"), new ImageIcon("image/c7.gif"),                                             new ImageIcon("image/c8.gif"), new ImageIcon("image/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);        }                }

效果圖<ignore_js_op>

詳細(xì)說(shuō)明:http://java.662p.com/thread-3209-1-1.html


發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 谢通门县| 尼木县| 祁阳县| 从江县| 隆德县| 绵阳市| 天长市| 嘉黎县| 武乡县| 石林| 鸡泽县| 长海县| 宁德市| 台中县| 呼伦贝尔市| 济宁市| 姜堰市| 精河县| 镇江市| 苍梧县| 绥芬河市| 泰和县| 宣武区| 漾濞| 河津市| 耿马| 繁峙县| 称多县| 敦煌市| 疏勒县| 蓬安县| 新乡市| 杭锦旗| 青岛市| 兴安县| 忻州市| 赤城县| 大名县| 无极县| 寿阳县| 行唐县|