Java mine clearance game source code case project, java mine clearance source code case

Source: Internet
Author: User

Java mine clearance game source code case project, java mine clearance source code case

The Code is as follows:

Import java. awt. *; import javax. swing. *; // graphic counter JCounter three 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); 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>

Http://java.662p.com/thread-3209-1-1.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.