-
Bug
-
Resolution: Fixed
-
P3
-
7, 8, 9
-
b61
-
generic
-
generic
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8084667 | emb-9 | Semyon Sadetsky | P3 | Resolved | Fixed | team |
When the last row in the table is selected,
removing another row may deselect the selected one
please follow this thread for more information:
http://forums.java.net/jive/thread.jspa?threadID=68361&tstart=0
import javax.swing.*;
import javax.swing.table.DefaultTableModel;
public class TableSortingBug {
private static void createGui() {
DefaultTableModel model = new DefaultTableModel(10, 1);
JTable table = new JTable(model);
// install a rowSorter
table.setAutoCreateRowSorter(true);
int last = table.getRowCount() - 1;
// select that last row
table.setRowSelectionInterval(last, last);
//sanity: really selected
if (!table.getSelectionModel().isSelectedIndex(last)) {
throw new RuntimeException();
}
// remove the second last
model.removeRow(last - 1);
if (table.getRowCount() - 1 != table.getSelectedRow()) {
throw new RuntimeException("last row must be still selected");
}
}
public static void main(String[] args) throws Exception {
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
TableSortingBug.createGui();
}
});
}
}
Reproducible with the latest JDK 6 and 7
removing another row may deselect the selected one
please follow this thread for more information:
http://forums.java.net/jive/thread.jspa?threadID=68361&tstart=0
import javax.swing.*;
import javax.swing.table.DefaultTableModel;
public class TableSortingBug {
private static void createGui() {
DefaultTableModel model = new DefaultTableModel(10, 1);
JTable table = new JTable(model);
// install a rowSorter
table.setAutoCreateRowSorter(true);
int last = table.getRowCount() - 1;
// select that last row
table.setRowSelectionInterval(last, last);
//sanity: really selected
if (!table.getSelectionModel().isSelectedIndex(last)) {
throw new RuntimeException();
}
// remove the second last
model.removeRow(last - 1);
if (table.getRowCount() - 1 != table.getSelectedRow()) {
throw new RuntimeException("last row must be still selected");
}
}
public static void main(String[] args) throws Exception {
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
TableSortingBug.createGui();
}
});
}
}
Reproducible with the latest JDK 6 and 7
- backported by
-
JDK-8084667 Removing rows from a DefaultTableModel with a RowSorter deselectes last row
- Resolved
- relates to
-
JDK-8158694 IOOBE in DefaultRowSorter.convertRowIndexToModel
- Closed
-
JDK-8076474 JTable.tableChanged(TableModelEvent e) specification need to be corrected
- Closed