Skip to content

Commit

Permalink
fix access to model data from sorted row
Browse files Browse the repository at this point in the history
  • Loading branch information
donald committed Oct 10, 2014
1 parent 093d250 commit a64e43c
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/de/mpg/molgen/buczek/portifix/Gui.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ private String[] columnValuesOfSelection(int col) {
int selected[] = jTable1.getSelectedRows();
String[] ret = new String[selected.length];
for (int i = 0; i < selected.length; i++) {
ret[i] = tableModel.getValueAt(selected[i], col).toString();
ret[i] = tableModel.getValueAt(jTable1.convertRowIndexToModel(selected[i]), col).toString();
}
return ret;
}
Expand Down Expand Up @@ -100,7 +100,8 @@ private void updateForm() {
} else {
String[] name = new String[selected.length];
for (int i = 0; i < name.length; i++) {
name[i] = tableModel.getValueAt(selected[i], 0) + " " + tableModel.getValueAt(selected[i], 1);
int mi=jTable1.convertRowIndexToModel(selected[i]);
name[i] = tableModel.getValueAt(mi, 1) + " " + tableModel.getValueAt(mi, 0);
}
jLabel_name.setText(singleColumnValueOfArray(name));
jLabel_abteilung.setText(singleColumnValueOfSelection(2));
Expand Down Expand Up @@ -135,7 +136,7 @@ private void saveThis() {
Date d = MyDateFormat.parse(s);
System.out.printf(" %s --> %s\n", s, d);
for (int i = 0; i < selected.length; i++) {
tableModel.setNewDateThis(selected[i], d);
tableModel.setNewDateThis(jTable1.convertRowIndexToModel(selected[i]), d);
}
} catch (ParseException exception) {
exception.printStackTrace();
Expand All @@ -149,7 +150,7 @@ private void saveAll() {
Date d = MyDateFormat.parse(s);
System.out.printf(" %s --> %s\n", s, d);
for (int i = 0; i < selected.length; i++) {
tableModel.setNewDateAll(selected[i], d);
tableModel.setNewDateAll(jTable1.convertRowIndexToModel(selected[i]), d);
}
} catch (ParseException exception) {
exception.printStackTrace();
Expand Down

0 comments on commit a64e43c

Please sign in to comment.