RFR: 8234071: JTable.AUTO_RESIZE_LAST_COLUMN acts like AUTO_RESIZE_ALL_COLUMNS [v2]

Abhishek Kumar abhiscxk at openjdk.org
Mon Jul 15 09:35:51 UTC 2024


On Mon, 15 Jul 2024 09:21:24 GMT, Prasanta Sadhukhan <psadhukhan at openjdk.org> wrote:

>> When a JTable is resized with` JTable.setAutoResizeMode` set to ` AUTO_RESIZE_LAST_COLUMN` then it behaves exactly as if I specified `AUTO_RESIZE_ALL_COLUMNS`. 
>> This is because when `JTable.doLayout` tries to resize the columns, it checks which column to resize by calling `getResizingColumn `and in absence of any column info, it resizes all, so during `setAutoResizeMode` the resizing column needs to be set, which is being done for AUTO_RESIZE_LAST_COLUMN in this fix.
>> No regression test is provided as it can be easily checked with SwingSet2->JTable(demo)->Autoresize mode (set to "Last Column")
>
> Prasanta Sadhukhan has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Prevent AIOBE

src/java.desktop/share/classes/javax/swing/JTable.java line 1270:

> 1268:             if (tableHeader != null) {
> 1269:                 if (mode == JTable.AUTO_RESIZE_LAST_COLUMN) {
> 1270:                     if (columnModel.getColumnCount() > 0) {

Conditions can be combined

`if (mode == JTable.AUTO_RESIZE_LAST_COLUMN
     && columnModel.getColumnCount() > 0) {`

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/20107#discussion_r1677553362


More information about the client-libs-dev mailing list