RFR: 8257810: Only First page are printed in JTable.scrollRectToVisible [v11]

Alexey Ivanov aivanov at openjdk.java.net
Wed May 11 18:11:07 UTC 2022


On Tue, 10 May 2022 06:26:29 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

test/jdk/javax/swing/JTable/PrintAllPagesTest.java line 63:

> 61:                     + " Test cannot continue.");
> 62:             PassFailJFrame.forcePass();
> 63:         }

This could be the first statements in main, as you don't even need to show the instructions in this case.

test/jdk/javax/swing/JTable/PrintAllPagesTest.java line 69:

> 67:         });
> 68: 
> 69:         Thread.sleep(1000);

The delay is not required here.

test/jdk/javax/swing/JTable/PrintAllPagesTest.java line 80:

> 78:             try {
> 79:                 if (!table.print()) {
> 80:                     throw new RuntimeException("Printing cancelled");

When run outside of jtreg, this exception doesn't stop the test. In jtreg, it does.

So it works as expected when run in jtreg but it could be confusing if run as a stand-alone test.

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

PR: https://git.openjdk.java.net/jdk/pull/8141



More information about the client-libs-dev mailing list