RFR: 8231865: JFXPanel sends resize event with size 0x0 on HiDPI devices

Andy Goryachev angorya at openjdk.org
Fri Jul 7 19:07:01 UTC 2023


On Mon, 3 Jul 2023 16:11:16 GMT, Prasanta Sadhukhan <psadhukhan at openjdk.org> wrote:

> If the scaleFactors used for the current device are not 1.0, a JXFPanel will send a resize event with 0x0 dimensions to the JavaFX scene which can have undesirable effects, which is because the resize pixel buffer is created even for initial size of 9x0 width,height.
> Fix is to make sure to prevent resizing the pixel buffer for initial width/height of 0.

modules/javafx.swing/src/main/java/javafx/embed/swing/JFXPanel.java line 631:

> 629:         if (oldWidth == 0 && oldHeight == 0 && pWidth == 0 && pHeight == 0) {
> 630:             return;
> 631:         }

this change fixes the issue with the provided test code.

a few comments:
1. if I wrap textArea with a BorderPane, I never get width=0 (master branch)
2. would it make sense to add a check to line 611: if((pWidth == 0) && (pHeight == 0))?
3. lines 617, 618 subtract border insets, would that risk making pWidth/pHeight negative (considering code on lines 613, 614)?

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

PR Review Comment: https://git.openjdk.org/jfx/pull/1168#discussion_r1256330975


More information about the openjfx-dev mailing list