Skip to content

Commit 4b3979f

Browse files
committed
Please enter the commit message for your changes. Lines starting
Info panel header added, first click is now guaranteed safe.
1 parent 333fbce commit 4b3979f

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

src/MineSweeper.java

+12-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import java.awt.Color;
22
import java.awt.Dimension;
3-
import java.awt.FlowLayout;
43
import java.awt.Font;
54
import java.awt.GridLayout;
65
import java.awt.Insets;
@@ -19,6 +18,7 @@
1918
import javax.swing.JOptionPane;
2019
import javax.swing.JPanel;
2120
import javax.swing.Timer;
21+
import javax.swing.UIManager;
2222
import javax.swing.border.EmptyBorder;
2323

2424
public class MineSweeper{
@@ -40,7 +40,7 @@ public class MineSweeper{
4040
static boolean boardGenerated = false;
4141
static int rows, cols;
4242
static int buttonSize = 40;
43-
static int bombAmount = 2;
43+
static int bombAmount = 40;
4444
static Timer timer;
4545
static int timeCount = 0;
4646

@@ -50,6 +50,10 @@ public class MineSweeper{
5050

5151
public static void initialize(){
5252

53+
try{
54+
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
55+
}catch (Exception e){}
56+
5357
rows = 20;
5458
cols = 30;
5559

@@ -59,7 +63,7 @@ public static void initialize(){
5963

6064
// initialize objects
6165
ran = new Random();
62-
frame = new JFrame("Tatti Sweeper");
66+
frame = new JFrame("Java Sweeper");
6367
board = new JPanel();
6468
display = new JPanel();
6569

@@ -81,13 +85,13 @@ public static void initialize(){
8185
bombs.setFont(text);
8286

8387
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)));
8589
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)));
8791
display.add(bombs);
8892
display.setBorder(new EmptyBorder(10, 0, 10, 0));
8993
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));
9195

9296
// setup JFrame
9397
frame.getContentPane().add(display);
@@ -145,9 +149,9 @@ public void mousePressed(MouseEvent e){
145149
int button = Integer.parseInt(((AbstractButton)e.getSource()).getActionCommand());
146150

147151
if(!boardGenerated && e.getButton() != MouseEvent.BUTTON3){
148-
152+
149153
startTimer();
150-
154+
151155
// generate board around first click
152156
generateBoard(button);
153157
sweep(button);

0 commit comments

Comments
 (0)