How do you pause a program until a button is pressed in JAVA?

Java program Double ActionPerformed Help !?

  • Making a checkers game on java. When I press a button it performs and action as it is supposed to but i want it to wait for 2nd button to be pressed to perform action. Help.codde so far: import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.*; public class Checkers implements ActionListener { JFrame frame = new JFrame("Checkers Board"); JButton button[]=new JButton[64]; public void ui() { frame.setVisible(true); frame.setSize(660,540); frame.setDefaultCloseOperation(JFram... frame.setTitle("SK's Checkers v1.1"); frame.setLayout(new GridLayout(8,8)); int d=0; for(int i=0;i<button.length;i++){ d++; if (d==27) {d++;} if (d%9==0){ d++;} if (d%2==0 && d<27) { button[i]= new JButton("X"); button[i].setOpaque(true); button[i].setToolTipText("Comp"); button[i].setForeground(Color.WHITE... button[i].setBackground(Color.BLACK... } else if (d%2==0 && d>45) { button[i]= new JButton("O"); button[i].setOpaque(true); button[i].setToolTipText("Your"); button[i].setForeground(Color.BLACK... button[i].setBackground(Color.WHITE... } else { button[i]= new JButton(""); } frame.add(button[i]); button[i].addActionListener(this); }} public void actionPerformed(ActionEvent arg0) { Object source = arg0.getSource(); int [] a; a = new int[button.length]; int [] b; b = new int[button.length]; for(int i=0;i<button.length;i++){ if (source == button[i] && button[i].getText()=="O") { a[i]=i; System.out.print(i +" "); } if (source == button[i] && button[i].getText()=="X") { b[i]=i; System.out.print(i +" "); }}}}

  • Answer:

    Restart the programming then... Good luck!

Sharoz Khalid at Yahoo! Answers Visit the source

Was this solution helpful to you?

Other answers

Restart the programming then... Good luck!

Related Q & A:

Just Added Q & A:

Find solution

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.