ASP源码.NET源码PHP源码JSP源码JAVA源码DELPHI源码PB源码VC源码VB源码Android源码

java 扫雷游戏源码案例项目

来源:网络整理     时间:2015-02-03     关键词:

本篇文章主要介绍了"java 扫雷游戏源码案例项目",主要涉及到方面的内容,对于Javajrs看球网直播吧_低调看直播体育app软件下载_低调看体育直播感兴趣的同学可以参考一下: 代码如下import java.awt.*;import javax.swing.*;//图形计数器JCounter三位class JCounter exten...

代码如下

import java.awt.*;
import javax.swing.*;

//图形计数器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);
        }

}

效果图

详细说明:http://java.662p.com/thread-3209-1-1.html

以上就介绍了java 扫雷游戏源码案例项目,包括了方面的内容,希望对Javajrs看球网直播吧_低调看直播体育app软件下载_低调看体育直播有兴趣的朋友有所帮助。

本文网址链接:http://www.codes51.com/article/detail_110838.html

相关图片

相关文章