On Tue, 18 Mar 2025 05:59:01 GMT, Prasanta Sadhukhan <psadhuk...@openjdk.org> wrote:
>> JTable.selectAll doesn't do anything if there are no rows or no columns. >> But it should still select all columns if there are no rows and the other >> way round. >> It is seen that isColumnSelected() will return false for all columns after >> calling selectAll() if there happened to be no rows. >> >> Fix is made to select all columns even if there are no rows and similarly >> for rows if there are no columns. > > Prasanta Sadhukhan has updated the pull request incrementally with one > additional commit since the last revision: > > Code duplication removed, subtest added src/java.desktop/share/classes/javax/swing/JTable.java line 2154: > 2152: int oldAnchor = > getAdjustedIndex(selModel.getAnchorSelectionIndex(), true); > 2153: > 2154: setRowSelectionInterval(0, rowCount-1); Suggestion: setRowSelectionInterval(0, rowCount - 1); src/java.desktop/share/classes/javax/swing/JTable.java line 2168: > 2166: int oldAnchor = > getAdjustedIndex(selModel.getAnchorSelectionIndex(), false); > 2167: > 2168: setColumnSelectionInterval(0, columnCount-1); Suggestion: setColumnSelectionInterval(0, columnCount - 1); src/java.desktop/share/classes/javax/swing/JTable.java line 2182: > 2180: int oldLead; > 2181: int oldAnchor; > 2182: ListSelectionModel selModel; Unused variable oldLead, oldAnchor, selModel test/jdk/javax/swing/JTable/TestTableSelectAll.java line 45: > 43: > 44: private static void testColumnSelect() { > 45: boolean colSelNoRow, colSelWithRow; Can be declare on separate lines. test/jdk/javax/swing/JTable/TestTableSelectAll.java line 62: > 60: // After selectAll(), I would expect all columns to be selected, > no matter > 61: // whether there are rows or not. > 62: System.out.println("Column 0 is selected: "+ colSelNoRow); Suggestion: System.out.println("Column 0 is selected: " + colSelNoRow); test/jdk/javax/swing/JTable/TestTableSelectAll.java line 69: > 67: > 68: colSelWithRow = table.isColumnSelected(0); > 69: System.out.println("Column 0 is selected: "+ colSelWithRow); Suggestion: System.out.println("Column 0 is selected: " + colSelWithRow); test/jdk/javax/swing/JTable/TestTableSelectAll.java line 77: > 75: > 76: private static void testRowSelect() { > 77: boolean rowSelNoColumn, rowSelWithColumn; Can be declare on separate lines. test/jdk/javax/swing/JTable/TestTableSelectAll.java line 84: > 82: JTable table = new JTable(data); > 83: > 84: // columns can be selected Suggestion: // rows can be selected test/jdk/javax/swing/JTable/TestTableSelectAll.java line 94: > 92: // After selectAll(), I would expect all rows to be selected, no > matter > 93: // whether there are columns or not. > 94: System.out.println("Row 0 is selected: "+ rowSelNoColumn); Suggestion: System.out.println("Row 0 is selected: " + rowSelNoColumn); test/jdk/javax/swing/JTable/TestTableSelectAll.java line 100: > 98: > 99: rowSelWithColumn = table.isRowSelected(0); > 100: System.out.println("Row 0 is selected: "+ rowSelWithColumn); Suggestion: System.out.println("Row 0 is selected: " + rowSelWithColumn); ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/24025#discussion_r2000310414 PR Review Comment: https://git.openjdk.org/jdk/pull/24025#discussion_r2000311674 PR Review Comment: https://git.openjdk.org/jdk/pull/24025#discussion_r2000311989 PR Review Comment: https://git.openjdk.org/jdk/pull/24025#discussion_r2000312998 PR Review Comment: https://git.openjdk.org/jdk/pull/24025#discussion_r2000316147 PR Review Comment: https://git.openjdk.org/jdk/pull/24025#discussion_r2000316380 PR Review Comment: https://git.openjdk.org/jdk/pull/24025#discussion_r2000317018 PR Review Comment: https://git.openjdk.org/jdk/pull/24025#discussion_r2000317445 PR Review Comment: https://git.openjdk.org/jdk/pull/24025#discussion_r2000317739 PR Review Comment: https://git.openjdk.org/jdk/pull/24025#discussion_r2000317890