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?
 
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
 
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
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.