Tictactoe java source code?
-
I’ve been working on a tic-tac-toe program and I’m stuck on a part where I’m trying to check if a player has won or not. Here is my code: import java.awt.*; import java.awt.event.*; import javax.swing.*; public class mygame extends JFrame implements ActionListener { private JPanel panel; private JLabel l; private JButton[] button; private String status; public mygame() { panel = new JPanel(); l = new JLabel("X'S TURN"); l.setPreferredSize(new Dimension(60,60)); status = "X"; for(int i=0;i<9;i++) { button[i]= new JButton(""); panel.add(button[i]); button[i].addActionListener(this); button[i].setPreferredSize(new Dimension(50,50)); button[i].setFont(new Font("sansserif", Font.BOLD, 32)); button[i].setFocusPainted(false); } panel.add(l); this.setResizable(false); this.setSize(150,210); this.setDefaultCloseOperation(JFrame… } public void actionPerformed(ActionEvent e) { for(int i=0; i<9; i++) { if(e.getSource()==button[i]) { button[i].setText("X"); button[i].setEnabled(false); status = "O'S TURN"; // button[i].checkStatus(this); } } } private void checkStatus(); { for(int i = 0; i<9;i++) { //this is what I’ve been trying to get if(button[i+2].getText().equals(butt… (button[i+1].getText().equals(button[… (button[i].getText().equals(button[i+… (button[i+2].getText().equals(button[… (button[i].getText().equals(button[i+… (button[i].getText().equals(button[i+… (button[i+3].getText().equals(button[… (button[i+6].getText().equals(button[… { }*/ } } public static void main(String[] args) { mygame test = new mygame(); } }
-
Answer:
Check in Google.
Drake Bijuu at Yahoo! Answers Visit the source
Related Q & A:
- How to Code Encryption Algorithm in Java?Best solution by code2learn.com
- How to Implement Gateway Service something similar to Oracle API gateway Using Java and Java based Open Source frameworks only?Best solution by Quora
- How to find the embed code for videos on a Website when it doesn't show in the source code?Best solution by Stack Overflow
- Where to find 'the art and Science of C' source code?Best solution by Stack Overflow
- Where to get ubuntu source code?Best solution by wiki.answers.com
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.