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

Alexey Ivanov aivanov at openjdk.java.net
Fri Apr 8 12:27:45 UTC 2022


On Fri, 8 Apr 2022 11:58:03 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 fix

Changes requested by aivanov (Reviewer).

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

> 49:     static JTable table;
> 50:     static boolean testResult = false;
> 51:     static CountDownLatch latch = new CountDownLatch(1);

`testResult` should be `volatile`.

`latch` should rather be `final`.

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

> 62:             SwingUtilities.invokeAndWait(() -> {
> 63:                 try {
> 64:                     table.print();

If user click Cancel in the print dialog, the `print` method returns `false`. The test should fail in this case.

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

> 70:             // wait for latch to complete
> 71:             if (!latch.await(5, TimeUnit.MINUTES)) {
> 72:                 throw new RuntimeException(" User has not executed the test");

Wouldn't the message "The test timed out" be clearer?

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

> 150:         mainPanel.add(buttonPanel, BorderLayout.SOUTH);
> 151:         dialog.add(mainPanel);
> 152:         dialog.setUndecorated(true);

It doesn't prevent you from using Alt+F4 to close the window but makes experience worse.

Is it possible to use JFrame instead of JDialog to display instructions?

If I accidentally switch to another window which overlaps the dialog, there's no way to bring it to the top other than minimizing all the windows that might overlap the dialog. If it's a frame, it's displayed in the Taskbar.

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

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



More information about the client-libs-dev mailing list