Like, I have one button: submit.
When I click this button, I take in the data and stuff.
Then I have a second button: done.
When I click this button, I close everything down.
I don't know how to have each button do it's own thing.
More specifically, here's the issue:
JPanel p = new JPanel(); p.setLayout(new GridLayout(5,5)); // add ActionListener for this submit button JButton submit = new JButton("Submit"); p.add(submit); submit.addActionListener(this); // add ActionListener for this done button JButton done = new JButton("Done"); p.add(submit); done.addActionListener(this);
Which all looks good but.....
the action listener definition is the same for both!!!!
public void actionPerformed(ActionEvent e) { // do submit stuff } public void actionPerformed(ActionEvent e) { // do done stuff }
This works with just the submit button but now I want to add the done button and I don't know what to do!!!