I\'m trying to make a stopwatch with three buttons, \"Start\", \"Pause\", and \"Stop\". My instructor only taught us how to set Action Listeners to two buttons. How do I set u
If you don't want to implement ActionListener you can add anonymous listener to your button like this:
JButton startButton = new JButton("Start");
JButton stopButton = new JButton("Stop");
JButton pauseButton = new JButton("Pause");
startButton.addActionListener(new ActionListener()
{
@Override
public void actionPerformed(ActionEvent e)
{
//start action logic here
}
});
stopButton.addActionListener(new ActionListener()
{
@Override
public void actionPerformed(ActionEvent e)
{
//stop action logic here
}
});
pauseButton.addActionListener(new ActionListener()
{
@Override
public void actionPerformed(ActionEvent e)
{
//action logic here
}
});
And this solution have to work :)