Link to home
Start Free TrialLog in
Avatar of jkteater
jkteaterFlag for United States of America

asked on

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
Avatar of for_yan
for_yan
Flag of United States of America image

show more of your code - taht probably has to do with how you handle the events so taht rthis method uis called many times ?
Avatar of jkteater

ASKER

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

ASKER CERTIFIED SOLUTION
Avatar of for_yan
for_yan
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
removing the FireDataChange did make it work correctly, but now I have to move the dialog to get the comments values to show up
add repaint() after you process the event
Yep - thanks