7
7
import gr .hmu .tp4768 .Models .GameMode ;
8
8
import java .awt .BorderLayout ;
9
9
import java .awt .Dimension ;
10
+
10
11
/**
11
12
* @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
+ *
16
17
*/
17
- public class GameFrame extends JFrame {
18
-
18
+ public class GameFrame extends JFrame {
19
+
19
20
private GameMode _gameMode ;
21
+
20
22
/**
21
23
* constructor
22
24
*/
23
- public GameFrame (GameMode gameMode ){
25
+ public GameFrame (GameMode gameMode ) {
24
26
_gameMode = gameMode ;
25
27
setTitle ("Minesweeper" );
26
28
initComponents ();
27
- setSize (new Dimension (500 , 500 ));
29
+ // set size based on difficulty
30
+ setSize (new Dimension (gameMode .getNumberOfRows () * 60 , gameMode .getNumberOfRows () * 40 + 100 ));
28
31
setDefaultCloseOperation (JFrame .EXIT_ON_CLOSE );
29
32
setLocationRelativeTo (null );
30
33
setResizable (false );
@@ -37,10 +40,10 @@ public GameFrame(GameMode gameMode){
37
40
* At the bottom of the frame is the status bar.
38
41
* At the center of the frame is the board.
39
42
*/
40
- public void initComponents (){
43
+ public void initComponents () {
41
44
GameToolBar gameToolBar = new GameToolBar (this );
42
45
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 ());
44
47
add (gameToolBar , BorderLayout .NORTH );
45
48
add (board , BorderLayout .CENTER );
46
49
add (statusBar , BorderLayout .SOUTH );
0 commit comments