The code is as follows
import java.awt.*;import javax.swing.*;//Graphics counter jcounter three-bit 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"), &nbSp; 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"), &Nbsp; }; 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) { &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;JFRAME&NBSP;JF = new jframe ("Test"); jf.setsize (23,39); jcounter jc = new jcounter (); jf.setcontentpane (JC); jf.show (); jc.resetcounter (394); } }
<ignore_js_op>650) this.width=650; "id=" aimg_1178 "class=" Zoom "src=" http://img.662p.com/java/forum/201410/ 18/125015fxn85mx8p0nen52a.jpg "width=" 405 "style=" border:0px; "/>
Detailed Description: http://java.662p.com/thread-3209-1-1.html
Java Minesweeper Game source case Project