Skip to content

Commit a8bb815

Browse files
committed
Update GameFrame.java
1 parent 4bd752f commit a8bb815

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

minesweeper/src/gr/hmu/tp4768/Views/GameFrame.java

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,27 @@
77
import gr.hmu.tp4768.Models.GameMode;
88
import java.awt.BorderLayout;
99
import java.awt.Dimension;
10+
1011
/**
1112
* @author tp4768
12-
*
13-
* GameFrame extends JFrame and creates the main window of the game.
14-
* It consists of , a game tool bar, a board and a status bar.
15-
*
13+
*
14+
* GameFrame extends JFrame and creates the main window of the game.
15+
* It consists of , a game tool bar, a board and a status bar.
16+
*
1617
*/
17-
public class GameFrame extends JFrame{
18-
18+
public class GameFrame extends JFrame {
19+
1920
private GameMode _gameMode;
21+
2022
/**
2123
* constructor
2224
*/
23-
public GameFrame(GameMode gameMode){
25+
public GameFrame(GameMode gameMode) {
2426
_gameMode = gameMode;
2527
setTitle("Minesweeper");
2628
initComponents();
27-
setSize(new Dimension(500, 500));
29+
// set size based on difficulty
30+
setSize(new Dimension(gameMode.getNumberOfRows() * 60, gameMode.getNumberOfRows() * 40 + 100));
2831
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
2932
setLocationRelativeTo(null);
3033
setResizable(false);
@@ -37,10 +40,10 @@ public GameFrame(GameMode gameMode){
3740
* At the bottom of the frame is the status bar.
3841
* At the center of the frame is the board.
3942
*/
40-
public void initComponents(){
43+
public void initComponents() {
4144
GameToolBar gameToolBar = new GameToolBar(this);
4245
Board board = new Board(this._gameMode);
43-
StatusBar statusBar = new StatusBar(this._gameMode.getNumberOfMines(),this._gameMode.getNumberOfFlags());
46+
StatusBar statusBar = new StatusBar(this._gameMode.getNumberOfMines(), this._gameMode.getNumberOfFlags());
4447
add(gameToolBar, BorderLayout.NORTH);
4548
add(board, BorderLayout.CENTER);
4649
add(statusBar, BorderLayout.SOUTH);

0 commit comments

Comments
 (0)