Since your using swing it's easy:
In the action performed method, just check which button was clicked and then add this line of code:
System.exit(0);
for example:
public void actionPerformed(ActionEvent ae)
{
if (ae.getSource() == doneButton)
{
System.exit(0);
}
}
server_crash
Postaholic
2,111 posts since Jun 2004
Reputation Points: 113
Solved Threads: 20
jeni
Remember that java matches on object references so the reference to doneButton should be the name you gave to the button object when you made it.
Not really. There are two ways of doing this:
JButton doneButton = new JButton("Done");
if (ae.getSource() == doneButton)
{
}
or
if (ae.getActionCommand().equals("Done"))
{
}
You can compare the actual object itself, or the name of it.
server_crash
Postaholic
2,111 posts since Jun 2004
Reputation Points: 113
Solved Threads: 20