-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCell.java
More file actions
102 lines (83 loc) · 2.52 KB
/
Copy pathCell.java
File metadata and controls
102 lines (83 loc) · 2.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
import javax.swing.*;
import java.awt.*;
import javax.swing.border.LineBorder;
public class Cell {
private JButton me;
private int l;
private boolean AmIBomb;
private int myEnemies;
private boolean AmIVisible;
private boolean AmIFlagged;
private int myX;
private int myY;
public Cell(int w,int myX, int myY){
this.myX = myX;
this.myY = myY;
this.me = new JButton();
this.AmIBomb = false;
this.AmIFlagged = false;
this.me.setSize(w,w);
this.me.setOpaque(true);
this.me.setBorderPainted(true);
this.me.setBackground(Color.WHITE);
this.me.setBorder(new LineBorder(new Color(175,175,175)));
}
public final JButton getButton(){
return this.me;
}
public final boolean isBomb(){
return this.AmIBomb;
}
public void becomeBomb(){
this.AmIBomb = true;
}
public void markAsFlagged(){
this.me.setBorderPainted(true);
this.me.setBorder(new LineBorder(new Color(175,175,175)));
Icon i = new ImageIcon("flag15.png");
this.me.setIcon(i);
this.AmIFlagged = true;
}
public void markAsNotFlagged(){
this.me.setIcon(null);
this.AmIFlagged = false;
}
public boolean isFlagged(){
return this.AmIFlagged;
}
public void turnVisible(){
this.AmIVisible = true;
this.me.setBackground(new Color(224,224,224));
if(this.AmIBomb){
Icon i = new ImageIcon("bomb15.png");
this.me.setIcon(i);
}else{
if (this.myEnemies != 0) this.me.setText(""+this.myEnemies);
switch (this.myEnemies) {
case 0 : break;
case 1 : this.me.setForeground(Color.BLUE); break;
case 2 : this.me.setForeground(Color.GREEN); break;
case 3 : this.me.setForeground(Color.RED); break;
case 4 : this.me.setForeground(new Color(100,0,255)); break;
case 5 : this.me.setForeground(new Color(200,0,200)); break;
case 6 : this.me.setForeground(new Color(150,0,0)); break;
default : break;
}
}
}
public boolean isVisible(){
return this.AmIVisible;
}
public final int getEnemies(){
return this.myEnemies;
}
public void setNumberText(int count){
this.myEnemies = count;
}
public final int getX(){
return this.myX;
}
public final int getY(){
return this.myY;
}
}