Multiple comments added

I am doing basically the same thing as the remove selected rows.
So I am selecting rows to add comments, but I want to append the same comment to all the rows selected, right now it poping the comments dialog box for every row in the selection

public void commentTableRow() {
      int[] row = selectTable.getSelectedRows();
      if (row.length > 0) {
         comment = JOptionPane.showInputDialog(null, "Please Enter Your Comment");
         for(int i = row.length-1; i >= 0; i--){
         //comment = JOptionPane.showInputDialog(null, "Please Enter Your Comment");
         myModel.commentSelectedRow(row[i], comment);
         }
      }
      else {
         JOptionPane.showMessageDialog(null, "You need to select a dataset to add the comment to.");
      }
   }

Open in new window


I moved the comment even above the for loop and it is still poping the dialog for every row selected
jkteaterAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

for_yanCommented:
show more of your code - taht probably has to do with how you handle the events so taht rthis method uis called many times ?
0
jkteaterAuthor Commented:
That method is called only once from the Add Comment Button

THis is the method is sending the data to

public void commentSelectedRow(int row, String comment) {
      if (rds.get(row).rComment == null) {
         rds.get(row).rComment = comment;
      }
      else {
         rds.get(row).rComment = null;
         rds.get(row).rComment = comment;
      }
      fireTableDataChanged();
      getCommentButton();
   }// end commentSelectedRow()

Open in new window

0
for_yanCommented:

If you have a button, perhpas you don't need
 fireTableDataChanged();

If you see optionpane more than once - it means your method
commentTableRow() is called more than once
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Become a CompTIA Certified Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

jkteaterAuthor Commented:
removing the FireDataChange did make it work correctly, but now I have to move the dialog to get the comments values to show up
0
for_yanCommented:
add repaint() after you process the event
0
jkteaterAuthor Commented:
Yep - thanks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.