RFR: JDK-7154070: in SwingSet2, switching between LaFs it's easy to lose JTable dividers [v5]
Alexey Ivanov
aivanov at openjdk.org
Wed Feb 8 10:17:48 UTC 2023
On Mon, 6 Feb 2023 10:14:12 GMT, Prasanta Sadhukhan <psadhukhan at openjdk.org> wrote:
>> In SwingSet2 in TableDemo, we can see grid dividers in Metal L&F but
>> if we Switch to the Nimbus LaF which has no grid dividers by default and then if we switch to Java (Metal): it will show no dividers.
>>
>> Issue is Nimbus call JTable.showGrid(false) in installDefaults but fail to reset in uninstallDefaults which is now rectified.
>>
>> No regression test is added as it can be verified by SwingSet2 Tabledemo..
>
> Prasanta Sadhukhan has updated the pull request incrementally with one additional commit since the last revision:
>
> Ignore set horiz/vert lines if showGrid is true by default
You should save the old values and always set the new value. In uninstall, you should restore the previous values.
For what it's worth, each Look and Feel must do it, otherwise there are other combinations of L&Fs where the property isn't restored.
The default value for `showHorizontalLines` and `showVerticalLines` is `false`. So it's changed by a L&F and is not restored.
Changes requested by aivanov (Reviewer).
src/java.desktop/share/classes/javax/swing/plaf/synth/SynthTableUI.java line 189:
> 187: if (!showGrid) {
> 188: table.setShowGrid(false);
> 189: }
What if the grid isn't displayed and `showGrid` is set to `true`? Then the value of `showGrid` isn't respected again.
src/java.desktop/share/classes/javax/swing/plaf/synth/SynthTableUI.java line 242:
> 240: table.setShowVerticalLines(true);
> 241: }
> 242: }
It should always restore the previous values.
test/jdk/javax/swing/JTable/TestJTableGridReset.java line 65:
> 63: table.setShowVerticalLines(true);
> 64: });
> 65: SwingUtilities.updateComponentTreeUI(table);
I'm pretty sure this method must also be called on EDT as it changes the state of Swing components.
-------------
Changes requested by aivanov (Reviewer).
PR: https://git.openjdk.org/jdk/pull/12385
More information about the client-libs-dev
mailing list