|
|
@ -4,6 +4,8 @@ import java.awt.Color; |
|
|
|
import java.awt.Point; |
|
|
|
import java.awt.event.ActionEvent; |
|
|
|
import java.awt.event.ActionListener; |
|
|
|
import java.awt.event.MouseAdapter; |
|
|
|
import java.awt.event.MouseEvent; |
|
|
|
|
|
|
|
import javax.swing.JButton; |
|
|
|
|
|
|
@ -32,6 +34,17 @@ public class Cell extends JButton { |
|
|
|
OnMouseClick(); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
addMouseListener(new MouseAdapter() { |
|
|
|
@Override |
|
|
|
public void mousePressed(MouseEvent e) { |
|
|
|
// TODO Auto-generated method stub |
|
|
|
super.mousePressed(e); |
|
|
|
if (e.getButton() == 3) { |
|
|
|
OnMouseRightClick(); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
protected void OnMouseClick() { |
|
|
@ -42,6 +55,14 @@ public class Cell extends JButton { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
protected void OnMouseRightClick() { |
|
|
|
if (flagged) { |
|
|
|
flagged = false; |
|
|
|
} else { |
|
|
|
flagged = true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public void update() { |
|
|
|
if (type == CellType.Number) { |
|
|
|
setText(String.valueOf(value)); |
|
|
|