consider the following code.
import edu.cmu.ri.createlab.terk.robot.finch.Finch;
import javax.swing.JFrame;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
public class RobotControl extends JFrame {
public static void main (String args[]) {
RobotControl GUI = new RobotControl();
GUI.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
GUI.setSize(500,500);
GUI.setVisible(true);
GUI.setTitle("RobotControl");
}
//The following are declarations of object variables.
private Finch myf;
private JButton front;
private JButton back;
private JButton left;
public RobotControl() {
myf = new Finch();
setLayout (new FlowLayout());
front = new JButton("front");
add(front);
front.addActionListener(new FrontButtonListener(myf));
back = new JButton("back");
add(back);
back.addActionListener(new BackButtonListener(myf));
left = new JButton("left");
add(left);
left.addActionListener(new LeftButtonListener(myf));
}
public class FrontButtonListener implements ActionListener {
public FrontButtonListener(Finch myf) {
// TODO Auto-generated constructor stub
}
public void actionPerformed(ActionEvent arg0) {
myf.setWheelVelocities(100,100,10000);
}
}
public class BackButtonListener implements ActionListener{
public BackButtonListener(Finch myf){
}
public void actionPerformed(ActionEvent arg0) {
myf.setWheelVelocities(-100,-100,10000);
}
}
public class LeftButtonListener implements ActionListener{
public LeftButtonListener(Finch myf){
}
public void actionPerformed(ActionEvent arg0){
myf.setWheelVelocities(0, 200, 1000);
}
Now, the code above will create a GUI, with three buttons, front, back, and left. I need some advice on how to make the program wait for all three buttons to be clicked before it runs, as opposed to clicking one button at a time.