Guys this how can i place an O automatically in a position that a omputer will generate?import java.awt.*; import java.awt.event.*; import javax.swing.*; public class Q implements ActionListener { /*Instance Variables*/ private JFrame window = new JFrame("Tic-Tac-Toe"); private JButton button1 = new JButton("1"); private JButton button2 = new JButton("2"); private JButton button3 = new JButton("3"); private JButton button4 = new JButton("4"); private JButton button5 = new JButton("5"); private JButton button6 = new JButton("6"); private JButton button7 = new JButton("7"); private JButton button8 = new JButton("8"); private JButton button9 = new JButton("9"); private String letter = ""; public static int count = 0; public Q() { [COLOR="#00FF00"]/*Create Window*/[/COLOR] window.setSize(300,300); window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); window.setLayout(new GridLayout(3,3)); [COLOR="#00FF00"]/*Add Buttons To The Window*/[/COLOR] window.add(button1); window.add(button2); window.add(button3); window.add(button4); window.add(button5); window.add(button6); window.add(button7); window.add(button8); window.add(button9); /*Add The Action Listener To The Buttons*/ button1.addActionListener(this); button2.addActionListener(this); button3.addActionListener(this); button4.addActionListener(this); button5.addActionListener(this); button6.addActionListener(this); button7.addActionListener(this); button8.addActionListener(this); button9.addActionListener(this); /*Make The Window Visible*/ window.setVisible(true); setCount(1); String input = JOptionPane.showInputDialog("welcome you will take X and computer wiil take O \n Please ENTER number you want to play "); int pawn = Integer.parseInt(input); if ( input.equals("1")) { button1.setText("X"); button1.setEnabled(false); //letter = "X"; } else if(input.equals("2")) { button2.setText("X"); button2.setEnabled(false); } else if(input.equals("3")) { button3.setText("X"); button3.setEnabled(false); } else if(input.equals("4")) { button4.setText("X"); button4.setEnabled(false); } else if(input.equals("5")) { button2.setText("X"); button5.setEnabled(false); } else if(input.equals("6")) { button6.setText("X"); button6.setEnabled(false); } else if(input.equals("7")) { button7.setText("X"); button7.setEnabled(false); } else if(input.equals("8")) { button8.setText("X"); button8.setEnabled(false); } else if(input.equals("9")) { button9.setText(letter); button9.setEnabled(false); } else { JOptionPane.showInputDialog("Sorry invalid number entered Please enter a number from 1 to 9 \n Press enter to procced "); } } public static void setCount (int co) { count = co; } public void actionPerformed(ActionEvent a) { count++; /*Calculate Who's Turn It Is*/ while(count == 2 || count == 4 || count == 6 || count == 8 || count == 10) { String input = JOptionPane.showInputDialog("welcome you will take X and computer wiil take O \n Please ENTER number you want to play "); int pawn = Integer.parseInt(input); if ( input.equals("1")) { button1.setText("X"); button1.setEnabled(false); //letter = "X"; } else if(input.equals("2")) { button2.setText("X"); button2.setEnabled(false); } else if(input.equals("X")) { button3.setText("X"); button3.setEnabled(false); } else if(input.equals("X")) { button4.setText("X"); button4.setEnabled(false); } else if(input.equals("X")) { button2.setText(letter); button5.setEnabled(false); } else if(input.equals("X")) { button6.setText("X"); button6.setEnabled(false); } else if(input.equals("X")) { button7.setText("X"); button7.setEnabled(false); } else if(input.equals("X")) { button8.setText("X"); button8.setEnabled(false); } else if(input.equals("X")) { button9.setText(letter); button9.setEnabled(false); } else { JOptionPane.showInputDialog("Sorry invalid number entered Please enter a number from 1 to 9 \n Press enter to procced "); }//letter = "X"; } //else if(count == 1|| count == 3 || count == 7 || count == 9 || count == 11) { int ran = 1 + (int)(Math.random() * 9); if (ran==1) { button1.setText("O"); button1.setEnabled(false); //letter = "X"; } else if(ran==2) { button2.setText("O"); button2.setEnabled(false); } else if(ran==3) { button3.setText("0"); button3.setEnabled(false); } else if(ran==4) { button4.setText("0"); button4.setEnabled(false); } else if(ran==5) { button5.setText("0"); button5.setEnabled(false); } else if(ran==6) { button6.setText("O"); button6.setEnabled(false); } else if(ran==7) { button7.setText("X"); button7.setEnabled(false); } else if(ran==8) { button8.setText("X"); button8.setEnabled(false); } else if(ran==9) { button9.setText(letter); button9.setEnabled(false); }//letter = "O"; } /*Display X's or O's on the buttons*/ if(a.getSource() == button1) { button1.setText(letter); button1.setEnabled(false); } else if(a.getSource() == button2) { button2.setText(letter); button2.setEnabled(false); } else if(a.getSource() == button3){ button3.setText(letter); button3.setEnabled(false); } else if(a.getSource() == button4){ button4.setText(letter); button4.setEnabled(false); } else if(a.getSource() == button5) { button5.setText(letter); button5.setEnabled(false); } else if(a.getSource() == button6) { button6.setText(letter); button6.setEnabled(false); } else if(a.getSource() == button7) { button7.setText(letter); button7.setEnabled(false); } else if(a.getSource() == button8) { button8.setText(letter); button8.setEnabled(false); } else if(a.getSource() == button9) { button9.setText(letter); button9.setEnabled(false); } } public static void main(String[] args) { new Q(); } }