Nur die besten Spiele ;3
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
1010 B

2 years ago
  1. package TicTacToe;
  2. import java.awt.Graphics;
  3. import java.awt.Graphics2D;
  4. import java.awt.geom.Line2D;
  5. import javax.swing.JFrame;
  6. import javax.swing.JPanel;
  7. public class TicTacToeGame extends JPanel {
  8. private static final long serialVersionUID = 1L;
  9. private static int width = 600, height = 600;
  10. public TicTacToeGame() {
  11. this.setSize(width, height);
  12. }
  13. public static void main(String[] args) {
  14. JFrame f = new JFrame();
  15. TicTacToeGame ttt = new TicTacToeGame();
  16. f.add(ttt);
  17. f.setSize(width,height);
  18. f.setLayout(null);
  19. f.setVisible(true);
  20. }
  21. @Override
  22. protected void paintComponent(Graphics g) {
  23. super.paintComponent(g);
  24. Graphics2D g2 = (Graphics2D) g;
  25. Line2D lin = new Line2D.Float(250, 150, 250, 450);
  26. Line2D lin2 = new Line2D.Float(350, 150, 350, 450);
  27. Line2D lin3 = new Line2D.Float(150, 250, 450, 250);
  28. Line2D lin4 = new Line2D.Float(150, 350, 450, 350);
  29. g2.draw(lin);
  30. g2.draw(lin2);
  31. g2.draw(lin3);
  32. g2.draw(lin4);
  33. }
  34. }