1
1
import java .awt .Color ;
2
2
import java .awt .Dimension ;
3
- import java .awt .FlowLayout ;
4
3
import java .awt .Font ;
5
4
import java .awt .GridLayout ;
6
5
import java .awt .Insets ;
19
18
import javax .swing .JOptionPane ;
20
19
import javax .swing .JPanel ;
21
20
import javax .swing .Timer ;
21
+ import javax .swing .UIManager ;
22
22
import javax .swing .border .EmptyBorder ;
23
23
24
24
public class MineSweeper {
@@ -40,7 +40,7 @@ public class MineSweeper{
40
40
static boolean boardGenerated = false ;
41
41
static int rows , cols ;
42
42
static int buttonSize = 40 ;
43
- static int bombAmount = 2 ;
43
+ static int bombAmount = 40 ;
44
44
static Timer timer ;
45
45
static int timeCount = 0 ;
46
46
@@ -50,6 +50,10 @@ public class MineSweeper{
50
50
51
51
public static void initialize (){
52
52
53
+ try {
54
+ UIManager .setLookAndFeel (UIManager .getSystemLookAndFeelClassName ());
55
+ }catch (Exception e ){}
56
+
53
57
rows = 20 ;
54
58
cols = 30 ;
55
59
@@ -59,7 +63,7 @@ public static void initialize(){
59
63
60
64
// initialize objects
61
65
ran = new Random ();
62
- frame = new JFrame ("Tatti Sweeper" );
66
+ frame = new JFrame ("Java Sweeper" );
63
67
board = new JPanel ();
64
68
display = new JPanel ();
65
69
@@ -81,13 +85,13 @@ public static void initialize(){
81
85
bombs .setFont (text );
82
86
83
87
display .add (time );
84
- display .add (Box .createRigidArea (new Dimension (buttonSize * cols / 10 ,0 )));
88
+ display .add (Box .createRigidArea (new Dimension (buttonSize * cols / 10 , 0 )));
85
89
display .add (remaining );
86
- display .add (Box .createRigidArea (new Dimension (buttonSize * cols / 10 ,0 )));
90
+ display .add (Box .createRigidArea (new Dimension (buttonSize * cols / 10 , 0 )));
87
91
display .add (bombs );
88
92
display .setBorder (new EmptyBorder (10 , 0 , 10 , 0 ));
89
93
display .setLayout (new BoxLayout (display , BoxLayout .X_AXIS ));
90
- //display.setLayout(new FlowLayout(FlowLayout.CENTER, buttonSize * cols / 10, 0));
94
+ // display.setLayout(new FlowLayout(FlowLayout.CENTER, buttonSize * cols / 10, 0));
91
95
92
96
// setup JFrame
93
97
frame .getContentPane ().add (display );
@@ -145,9 +149,9 @@ public void mousePressed(MouseEvent e){
145
149
int button = Integer .parseInt (((AbstractButton )e .getSource ()).getActionCommand ());
146
150
147
151
if (!boardGenerated && e .getButton () != MouseEvent .BUTTON3 ){
148
-
152
+
149
153
startTimer ();
150
-
154
+
151
155
// generate board around first click
152
156
generateBoard (button );
153
157
sweep (button );
0 commit comments