@@ -103,6 +103,8 @@ public class Game extends JPanel implements MouseListener, MouseMotionListener {
103
103
private Color timerFontColor ;
104
104
private Color openTerrainBoarderColor ;
105
105
private Color counterDigitColor ;
106
+ private Font timerFont ;
107
+ private Font buttonFont ;
106
108
107
109
108
110
// images
@@ -116,14 +118,17 @@ public Game(JFrame frame) {
116
118
117
119
// change the color if needed
118
120
119
- bgColor = new Color (234 , 242 , 255 ,(int ) (0.7 * 255 )); // 0.7 is the opacity
121
+ bgColor = new Color (234 , 242 , 255 , (int ) (0.7 * 255 )); // 0.7 is the opacity
120
122
openTerrainColor = new Color (255 , 255 , 255 , (int ) (0.5 * 255 ));
121
123
openTerrainBoarderColor = new Color (0 , 0 , 0 , (int ) (0.5 * 255 ));
122
124
123
125
counterDigitColor = new Color (255 , 0 , 0 , (int ) (1.0 * 255 ));
124
126
125
127
footerColor = new Color (0 , 0 , 255 , (int ) (0.1 * 255 ));
126
- timerFontColor = new Color (255 , 0 , 155 , (int ) (1.0 * 255 ));
128
+ timerFontColor = new Color (0 , 0 , 0 , (int ) (1.0 * 255 ));
129
+
130
+ timerFont = new Font ("Arial" , Font .BOLD , 18 );
131
+ buttonFont = new Font ("Arial" , Font .PLAIN , 12 );
127
132
128
133
// -------------------------
129
134
@@ -215,6 +220,7 @@ private void loadImg() {
215
220
216
221
private void resetButton () {
217
222
JButton result = new JButton ("Reset" );
223
+ result .setFont (buttonFont );
218
224
result .addActionListener (new ActionListener () {
219
225
@ Override
220
226
public void actionPerformed (ActionEvent e ) {
@@ -253,6 +259,7 @@ public void actionPerformed(ActionEvent e) {
253
259
private void selectOpenTerrain () {
254
260
// Create the reset button
255
261
JButton result = new JButton ("<html>Open Terrain<br/><center><font size='2'>Cost: 1</font></center></html>" );
262
+ result .setFont (buttonFont );
256
263
result .addActionListener (new ActionListener () {
257
264
@ Override
258
265
public void actionPerformed (ActionEvent e ) {
@@ -269,6 +276,7 @@ public void actionPerformed(ActionEvent e) {
269
276
270
277
private void selectSwampland () {
271
278
JButton result = new JButton ("<html>Swampland<br/><center><font size='2'>Cost: 4</font></center></html>" );
279
+ result .setFont (buttonFont );
272
280
result .addActionListener (new ActionListener () {
273
281
@ Override
274
282
public void actionPerformed (ActionEvent e ) {
@@ -285,6 +293,8 @@ public void actionPerformed(ActionEvent e) {
285
293
286
294
private void selectGrassland () {
287
295
JButton result = new JButton ("<html>Grassland<br/><center><font size='2'>Cost: 3</font></center></html>" );
296
+ result .setFont (buttonFont );
297
+
288
298
result .addActionListener (new ActionListener () {
289
299
@ Override
290
300
public void actionPerformed (ActionEvent e ) {
@@ -303,6 +313,8 @@ public void actionPerformed(ActionEvent e) {
303
313
// search button to start the search algorithm
304
314
private JButton searchButton () {
305
315
JButton result = new JButton ("A* Search" );
316
+ result .setFont (buttonFont );
317
+
306
318
result .addActionListener (new ActionListener () {
307
319
@ Override
308
320
public void actionPerformed (ActionEvent e ) {
@@ -344,6 +356,7 @@ private void resetCameFrom(Tile[][] tiles) {
344
356
345
357
private void selectGoalLocation () {
346
358
JButton result = new JButton ("Goal" );
359
+ result .setFont (buttonFont );
347
360
result .addActionListener (new ActionListener () {
348
361
@ Override
349
362
public void actionPerformed (ActionEvent e ) {
@@ -360,6 +373,7 @@ public void actionPerformed(ActionEvent e) {
360
373
361
374
public void selectStartLocation () {
362
375
JButton result = new JButton ("Start" );
376
+ result .setFont (buttonFont );
363
377
result .addActionListener (new ActionListener () {
364
378
@ Override
365
379
public void actionPerformed (ActionEvent e ) {
@@ -376,6 +390,7 @@ public void actionPerformed(ActionEvent e) {
376
390
377
391
public void selectObstacle () {
378
392
JButton result = new JButton ("<html><center>Obstacle<br/><font size='2'>Cost: Impossible</font></center></html>" );
393
+ result .setFont (buttonFont );
379
394
result .addActionListener (new ActionListener () {
380
395
@ Override
381
396
public void actionPerformed (ActionEvent e ) {
@@ -728,7 +743,7 @@ private void printTimer(Graphics g) {
728
743
timerX = frame .getWidth () - 620 ;
729
744
timerY = frame .getHeight () - 47 ;
730
745
g .setColor (timerFontColor ); // Sets the color to red.
731
- g .setFont (new Font ( "Courier New" , Font . PLAIN , 20 ) );
746
+ g .setFont (timerFont );
732
747
g .drawString ("Creation Time: " + elapsedTimeStringBeforeSearch , timerX , timerY );
733
748
g .setColor (Color .BLACK );
734
749
g .drawString ("|" , timerX + 283 , timerY );
0 commit comments