|
|
@ -0,0 +1,48 @@ |
|
|
|
package TicTacToe; |
|
|
|
|
|
|
|
import java.awt.Graphics; |
|
|
|
import java.awt.Graphics2D; |
|
|
|
import java.awt.geom.Line2D; |
|
|
|
|
|
|
|
import javax.swing.JFrame; |
|
|
|
import javax.swing.JPanel; |
|
|
|
|
|
|
|
|
|
|
|
public class TicTacToeGame extends JPanel { |
|
|
|
|
|
|
|
private static final long serialVersionUID = 1L; |
|
|
|
private static int width = 600, height = 600; |
|
|
|
|
|
|
|
public TicTacToeGame() { |
|
|
|
this.setSize(width, height); |
|
|
|
} |
|
|
|
|
|
|
|
public static void main(String[] args) { |
|
|
|
|
|
|
|
JFrame f = new JFrame(); |
|
|
|
TicTacToeGame ttt = new TicTacToeGame(); |
|
|
|
|
|
|
|
f.add(ttt); |
|
|
|
f.setSize(width,height); |
|
|
|
f.setLayout(null); |
|
|
|
f.setVisible(true); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
protected void paintComponent(Graphics g) { |
|
|
|
super.paintComponent(g); |
|
|
|
Graphics2D g2 = (Graphics2D) g; |
|
|
|
|
|
|
|
Line2D lin = new Line2D.Float(250, 150, 250, 450); |
|
|
|
Line2D lin2 = new Line2D.Float(350, 150, 350, 450); |
|
|
|
Line2D lin3 = new Line2D.Float(150, 250, 450, 250); |
|
|
|
Line2D lin4 = new Line2D.Float(150, 350, 450, 350); |
|
|
|
|
|
|
|
g2.draw(lin); |
|
|
|
g2.draw(lin2); |
|
|
|
g2.draw(lin3); |
|
|
|
g2.draw(lin4); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |