Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package game;
- import javax.swing.ImageIcon;
- import javax.swing.JButton;
- import java.awt.event.ActionListener;
- import java.awt.event.ActionEvent;
- public class XOButton extends JButton{
- ImageIcon X,O;
- byte value = 0;
- public XOButton(){
- X = new ImageIcon(this.getClass().getResource("X.png"));
- O = new ImageIcon(this.getClass().getResource("O.png"));
- this.addActionListener((ActionListener) this);
- }
- public void actionPerformed(ActionEvent e){
- value++;
- value%=3;
- switch(value){
- case 0:
- setIcon(null);
- break;
- case 1:
- setIcon(X);
- break;
- case 2:
- setIcon(O);
- break;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement