RFR: 8257810: Only First page are printed in JTable.scrollRectToVisible [v3]
Alexey Ivanov
aivanov at openjdk.java.net
Fri Apr 8 11:36:41 UTC 2022
On Thu, 7 Apr 2022 14:59:38 GMT, Prasanta Sadhukhan <psadhukhan at openjdk.org> wrote:
>> Issue was when printing a JTable which sits inside a JScrollPane and the table is scrolled down to the end to about 1000th row, only the first page is printed.
>> This is because when the table is scrolled down to last page, the bounds.y becomes -ve
>> [x=0,y=-15260,width=968,height=16000]
>> so the check `if (!((table.getBounds()).intersects(clip)))` is satisfied only for 1st page where bounds just intersects the clip [x=0,y=0,width=968,height=1296]
>> but subsequent pages clip
>> [[x=0,y=1296,width=968,height=1296],
>> [x=0,y=2592,width=968,height=1296],
>> [x=0,y=3888,width=968,height=1296] etc is not intesecting so they are not printed
>>
>> This is a regression of JDK-8081491 which was **reworked** in JDK-8236907 where the bounds calculation and usage is made same as in BasicTableUI
>> We need to use the same resetted bounds for this intersection calculation too as was done for JDK-8236907
>>
>> Tested against JDK-8081491, 8170349, JDK-8236907 testcases along with other regression tests and all are OK (link in JBS)
>
> Prasanta Sadhukhan has updated the pull request incrementally with one additional commit since the last revision:
>
> Test updated
Closing the dialog or the frame should fail the test as well.
test/jdk/javax/swing/JTable/PrintAllPagesTest.java line 31:
> 29: import java.awt.BorderLayout;
> 30: import java.awt.FlowLayout;
> 31: import java.awt.Rectangle;
This is an unused import.
test/jdk/javax/swing/JTable/PrintAllPagesTest.java line 75:
> 73: ret = latch.await(5, TimeUnit.MINUTES);
> 74:
> 75: if (!ret) {
Suggestion:
if (!latch.await(5, TimeUnit.MINUTES)) {
The variable is redundant now.
test/jdk/javax/swing/JTable/PrintAllPagesTest.java line 79:
> 77: }
> 78:
> 79: if (testResult == false) {
Suggestion:
if (!testResult) {
Looks cleaner, doesn't it? And produces no warning in the IDE.
test/jdk/javax/swing/JTable/PrintAllPagesTest.java line 85:
> 83: SwingUtilities.invokeAndWait(() -> {
> 84: dispose();
> 85: });
I prefer method references in this case yet I don't insist.
However, this fits perfectly with the usages above.
test/jdk/javax/swing/JTable/PrintAllPagesTest.java line 147:
> 145: failButton.addActionListener((e) -> {
> 146: testResult = false;
> 147: dispose();
Now that the UI is always dispose of in a finally block, the button handlers can skip the call to `dispose()`.
-------------
Changes requested by aivanov (Reviewer).
PR: https://git.openjdk.java.net/jdk/pull/8141
More information about the client-libs-dev
mailing list