Guest User

Untitled

a guest
Sep 7th, 2014
251
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.15 KB | None | 0 0
  1.  
  2.  
  3. public class aaaaaaaaaaaaa extends JFrame {
  4.  
  5. private JPanel contentPane;
  6.  
  7. public static void main(String[] args) {
  8. EventQueue.invokeLater(new Runnable() {
  9. public void run() {
  10. try {
  11. aaaaaaaaaaaaa frame = new aaaaaaaaaaaaa();
  12. frame.setVisible(true);
  13. } catch (Exception e) {
  14. e.printStackTrace();
  15. }
  16. }
  17. });
  18. }
  19.  
  20.  
  21. public aaaaaaaaaaaaa() {
  22.  
  23. boolean jogador = true;
  24.  
  25. setTitle("Jogo da Velha");
  26. setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  27. setBounds(100, 100, 434, 350);
  28. contentPane = new JPanel();
  29. contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
  30. setContentPane(contentPane);
  31. contentPane.setLayout(null);
  32.  
  33. final JButton b1 = new JButton("");
  34. b1.setBackground(SystemColor.menu);
  35. b1.setBounds(10, 11, 107, 61);
  36. contentPane.add(b1);
  37.  
  38. final JButton b2 = new JButton("");
  39. b2.setBackground(SystemColor.menu);
  40. b2.setBounds(145, 11, 107, 61);
  41. contentPane.add(b2);
  42.  
  43. final JButton b3 = new JButton("");
  44. b3.setBackground(SystemColor.menu);
  45. b3.setBounds(281, 11, 107, 61);
  46. contentPane.add(b3);
  47.  
  48. final JButton b4 = new JButton("");
  49. b4.setBackground(SystemColor.menu);
  50. b4.setBounds(281, 95, 107, 61);
  51. contentPane.add(b4);
  52.  
  53. final JButton b5 = new JButton("");
  54. b5.setBackground(SystemColor.menu);
  55. b5.setBounds(145, 95, 107, 61);
  56. contentPane.add(b5);
  57.  
  58. final JButton b6 = new JButton("");
  59. b6.setBackground(SystemColor.menu);
  60. b6.setBounds(10, 95, 107, 61);
  61. contentPane.add(b6);
  62.  
  63. final JButton b7 = new JButton("");
  64. b7.setBackground(SystemColor.menu);
  65. b7.setBounds(10, 175, 107, 61);
  66. contentPane.add(b7);
  67.  
  68. final JButton b8 = new JButton("");
  69. b8.setBackground(SystemColor.menu);
  70. b8.setBounds(145, 175, 107, 61);
  71. contentPane.add(b8);
  72.  
  73. final JButton b9 = new JButton("");
  74. b9.setBackground(SystemColor.menu);
  75. b9.setBounds(281, 175, 107, 61);
  76. contentPane.add(b9);
  77.  
  78.  
  79.  
  80.  
  81. if(jogador == true ){
  82. jogador =! jogador;
  83. // B1
  84. b1.addActionListener(new ActionListener() {
  85.  
  86.  
  87. public void actionPerformed(ActionEvent arg0) {
  88. b1.setText("X");
  89.  
  90. }
  91. });
  92. // B2
  93. b2.addActionListener(new ActionListener() {
  94.  
  95.  
  96. public void actionPerformed(ActionEvent arg0) {
  97. b2.setText("X");
  98.  
  99. }
  100. });
  101.  
  102.  
  103. // B3
  104.  
  105. b3.addActionListener(new ActionListener() {
  106.  
  107.  
  108. public void actionPerformed(ActionEvent arg0) {
  109. b3.setText("X");
  110.  
  111. }
  112. });
  113.  
  114. // B4
  115.  
  116. b4.addActionListener(new ActionListener() {
  117.  
  118.  
  119. public void actionPerformed(ActionEvent arg0) {
  120. b4.setText("X");
  121.  
  122. }
  123. });
  124.  
  125.  
  126. // B5
  127. b5.addActionListener(new ActionListener() {
  128.  
  129.  
  130. public void actionPerformed(ActionEvent arg0) {
  131. b5.setText("X");
  132.  
  133. }
  134. });
  135.  
  136. // B6
  137. b6.addActionListener(new ActionListener() {
  138.  
  139.  
  140. public void actionPerformed(ActionEvent arg0) {
  141. b6.setText("X");
  142.  
  143. }
  144. });
  145.  
  146. // B7
  147.  
  148. b7.addActionListener(new ActionListener() {
  149.  
  150. public void actionPerformed(ActionEvent arg0) {
  151. b7.setText("X");
  152.  
  153. }
  154. });
  155.  
  156. // B8
  157.  
  158. b8.addActionListener(new ActionListener() {
  159.  
  160. public void actionPerformed(ActionEvent arg0) {
  161. b8.setText("X");
  162.  
  163. }
  164. });
  165.  
  166.  
  167. // B9
  168.  
  169. b9.addActionListener(new ActionListener() {
  170.  
  171. public void actionPerformed(ActionEvent arg0) {
  172. b9.setText("X");
  173.  
  174. }
  175. });
  176.  
  177.  
  178. }
  179.  
  180. if(jogador != true){
  181.  
  182. jogador =! jogador;
  183.  
  184. b1.addActionListener(new ActionListener() {
  185.  
  186.  
  187. public void actionPerformed(ActionEvent arg0) {
  188. b1.setText("O");
  189.  
  190.  
  191. }
  192. });
  193. // B2
  194. b2.addActionListener(new ActionListener() {
  195.  
  196.  
  197. public void actionPerformed(ActionEvent arg0) {
  198. b2.setText("O");
  199.  
  200. }
  201. });
  202.  
  203.  
  204. // B3
  205.  
  206. b3.addActionListener(new ActionListener() {
  207.  
  208.  
  209. public void actionPerformed(ActionEvent arg0) {
  210. b3.setText("O");
  211.  
  212. }
  213. });
  214.  
  215. // B4
  216.  
  217. b4.addActionListener(new ActionListener() {
  218.  
  219.  
  220. public void actionPerformed(ActionEvent arg0) {
  221. b4.setText("O");
  222.  
  223. }
  224. });
  225.  
  226.  
  227. // B5
  228. b5.addActionListener(new ActionListener() {
  229.  
  230.  
  231. public void actionPerformed(ActionEvent arg0) {
  232. b5.setText("O");
  233.  
  234. }
  235. });
  236.  
  237. // B6
  238. b6.addActionListener(new ActionListener() {
  239.  
  240.  
  241. public void actionPerformed(ActionEvent arg0) {
  242. b6.setText("O");
  243.  
  244. }
  245. });
  246.  
  247. // B7
  248.  
  249. b7.addActionListener(new ActionListener() {
  250.  
  251.  
  252. public void actionPerformed(ActionEvent arg0) {
  253. b7.setText("O");
  254.  
  255. }
  256. });
  257.  
  258. // B8
  259.  
  260. b8.addActionListener(new ActionListener() {
  261.  
  262.  
  263. public void actionPerformed(ActionEvent arg0) {
  264. b8.setText("O");
  265.  
  266. }
  267. });
  268.  
  269.  
  270. // B9
  271.  
  272. b9.addActionListener(new ActionListener() {
  273.  
  274.  
  275. public void actionPerformed(ActionEvent arg0) {
  276. b9.setText("O");
  277.  
  278. }
  279. });
  280.  
  281.  
  282. }
  283.  
  284.  
  285.  
  286. }
  287. }
Advertisement
Add Comment
Please, Sign In to add comment