b.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
if(table.getSelectedRow()<0) // help required to implement this logic!!
{
JOptionPane.showInternalMessageDialog(rootPane, "Please select a row from the table first!");
...
At a quick look what you've got seems OK. What exactly is the problem with the code you posted?
JamesCherrill
Posting Genius
6,373 posts since Apr 2008
Reputation Points: 2,130
Solved Threads: 1,073
Time for some debugging:
Add a print statement at the start of your actionPerformed to see if its being called.
Print table.getSelectedRow() just before the if, to see if it's what you expected.
JamesCherrill
Posting Genius
6,373 posts since Apr 2008
Reputation Points: 2,130
Solved Threads: 1,073
^ yes! Well spotted! Yet another demo of why correct indentation is essential.
JamesCherrill
Posting Genius
6,373 posts since Apr 2008
Reputation Points: 2,130
Solved Threads: 1,073