jkteater
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
I moved the comment even above the for loop and it is still poping the dialog for every row selected
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.");
}
}
I moved the comment even above the for loop and it is still poping the dialog for every row selected
show more of your code - taht probably has to do with how you handle the events so taht rthis method uis called many times ?
ASKER
That method is called only once from the Add Comment Button
THis is the method is sending the data to
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()
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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
ASKER
Yep - thanks