RFR: 5108458: JTable does not properly layout its content [v6]
Alexey Ivanov
aivanov at openjdk.org
Tue Nov 21 17:06:17 UTC 2023
On Tue, 21 Nov 2023 16:54:28 GMT, Alexey Ivanov <aivanov at openjdk.org> wrote:
>> src/java.desktop/share/classes/javax/swing/plaf/basic/BasicTableUI.java line 2031:
>>
>>> 2029: damagedArea.x = SwingUtilities2.getXPosInRightToLeft(table, cMin);
>>> 2030: } else {
>>> 2031: damagedArea.x = SwingUtilities2.getXPosInRightToLeft(table, cMax);
>>
>> Does it mean that `table.getCellRect` returns an incorrect value in right-to-left case?
>
>> Does it mean that `table.getCellRect` returns an incorrect value in right-to-left case?
>
> Yes, it does! Clicking to select doesn't work correctly: wherever I click only the Salary column gets selected, there's no way to move selection to another cell (*visibly* at least), editing doesn't work either: if I select the Salary cell in the first row and press F2 to edit the value, the editor appears in the left top corner where the cell rendered before the fix.
>
> To enable editing, add
>
>
> @Override
> public boolean isCellEditable(int rowIndex, int columnIndex) {
> return true;
> }
>
>
> to the `Model` class.
> there's no way to move selection to another cell (_visibly_ at least)
Yes, the selection moves but you can't see it. Moving the cell to editable state brings up the editor which is positioned like on [your screenshot above](https://github.com/openjdk/jdk/pull/16374#discussion_r1400007130) without the fix.
It looks to me what you should actually change is the implementation of `JTable.getCellRect` so that returns the *correct* coordinates when the orientation is set to right-to-left and rendering will fix automatically.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/16374#discussion_r1400906937
More information about the client-libs-dev
mailing list