forked from otakaran/tic-tac-toe
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathButton.java
42 lines (38 loc) · 979 Bytes
/
Button.java
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
import javax.swing.*;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
/**
* This class generates button objects used in the GUI.
*
* @author Ping-Chun Chung and Otakar Andrysek
* @version v1.0.1
*/
public class Button extends JButton
{
ImageIcon X,O;
// Prepares X and O images for placing
public Button()
{
X =new ImageIcon(this.getClass().getResource("ima/X.png"));
O =new ImageIcon(this.getClass().getResource("ima/O.png"));
setBorderPainted(false);
setFocusPainted(false);
setContentAreaFilled(false);
}
// Inserts X and O images into board
public void setImaIcon(String icon)
{
if (icon.equals("-"))
{
setIcon(null);
}
else if (icon.equals("X"))
{
setIcon(X);
}
else if (icon.equals("O"))
{
setIcon(O);
}
}
}