RFR: 5108458: JTable does not properly layout its content [v4]

Damon Nguyen dnguyen at openjdk.org
Wed Nov 15 19:19:40 UTC 2023


On Fri, 10 Nov 2023 07:31:19 GMT, Tejesh R <tr at openjdk.org> wrote:

>> Table contents does not follow right-left Orientation when Max width of columns are set. This is due to not considering the offset in `x position` while painting table grid and table cell. The fix handles the offset and adjust the x position for each paint, similar to how header is painted. The fix is applied to both Basic and Synth Look and Feel. 
>> The fix is verified for all Look and Feel manually and test verifies on Metal L&F since automatic test cannot be generalized throughout other Look and Feel. 
>> CI tested is green for regression check and test check.
>
> Tejesh R has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Review fix

There's plenty of places where the for loop is missing a space as well. Seems like there are a lot though, so I'll leave it up to you whether or not it should be fixed with this update. Would seem odd to have a space before some () and not after some others.

src/java.desktop/share/classes/javax/swing/plaf/basic/BasicTableUI.java line 2088:

> 2086:                 cellRect = table.getCellRect(row, cMin, false);
> 2087:                 cellRect.x = getXPosition(cMin);
> 2088:                 for(int column = cMin; column <= cMax; column++) {

Suggestion:

            for (int row = rMin; row <= rMax; row++) {
                cellRect = table.getCellRect(row, cMin, false);
                cellRect.x = getXPosition(cMin);
                for (int column = cMin; column <= cMax; column++) {

src/java.desktop/share/classes/javax/swing/plaf/basic/BasicTableUI.java line 2099:

> 2097:             }
> 2098:         } else {
> 2099:             for(int row = rMin; row <= rMax; row++) {

Suggestion:

            for (int row = rMin; row <= rMax; row++) {

src/java.desktop/share/classes/javax/swing/plaf/basic/BasicTableUI.java line 2102:

> 2100:                 cellRect = table.getCellRect(row, cMin, false);
> 2101:                 cellRect.x = getXPosition(cMax);
> 2102:                 for(int column = cMax; column >= cMin; column--) {

Suggestion:

                for (int column = cMax; column >= cMin; column--) {

src/java.desktop/share/classes/javax/swing/plaf/synth/SynthTableUI.java line 589:

> 587:         int columnWidth;
> 588:         if (table.getComponentOrientation().isLeftToRight()) {
> 589:             for(int row = rMin; row <= rMax; row++) {

Suggestion:

            for (int row = rMin; row <= rMax; row++) {

src/java.desktop/share/classes/javax/swing/plaf/synth/SynthTableUI.java line 592:

> 590:                 cellRect = table.getCellRect(row, cMin, false);
> 591:                 cellRect.x = getXPosition(cMin);
> 592:                 for(int column = cMin; column <= cMax; column++) {

Suggestion:

                for (int column = cMin; column <= cMax; column++) {

src/java.desktop/share/classes/javax/swing/plaf/synth/SynthTableUI.java line 603:

> 601:             }
> 602:         } else {
> 603:             for(int row = rMin; row <= rMax; row++) {

Suggestion:

            for (int row = rMin; row <= rMax; row++) {

src/java.desktop/share/classes/javax/swing/plaf/synth/SynthTableUI.java line 612:

> 610:                     paintCell(context, g, cellRect, row, cMax);
> 611:                 }
> 612:                 for(int column = cMax-1; column >= cMin; column--) {

Suggestion:

                for (int column = cMax-1; column >= cMin; column--) {

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

PR Review: https://git.openjdk.org/jdk/pull/16374#pullrequestreview-1732745770
PR Review Comment: https://git.openjdk.org/jdk/pull/16374#discussion_r1394667057
PR Review Comment: https://git.openjdk.org/jdk/pull/16374#discussion_r1394666897
PR Review Comment: https://git.openjdk.org/jdk/pull/16374#discussion_r1394666771
PR Review Comment: https://git.openjdk.org/jdk/pull/16374#discussion_r1394665306
PR Review Comment: https://git.openjdk.org/jdk/pull/16374#discussion_r1394665452
PR Review Comment: https://git.openjdk.org/jdk/pull/16374#discussion_r1394665628
PR Review Comment: https://git.openjdk.org/jdk/pull/16374#discussion_r1394665829


More information about the client-libs-dev mailing list