On Wed, 4 Oct 2023 05:48:59 GMT, Prasanta Sadhukhan <[email protected]> 
wrote:

>> SwingNode does not update its internal cache of Swing pref/max/min height 
>> and widths when its JComponent content's corresponding size constraints are 
>> updated. As such, it isn't resized to honor those size constraints. 
>> 
>> JLightweightFrame does install a PropertyChangeListener for "preferredSize", 
>> "maximumSize", and "minimumSize" properties, but this only happens via a 
>> ContainerListener which is not added until after the content has already 
>> been added to the content pane, and since the application cannot call this 
>> methods directly as per the documentation for the SwingNode.resize() method: 
>> `Applications should not invoke this method directly. If an application 
>> needs to directly set the size of the SwingNode, it should set the Swing 
>> component's minimum/preferred/maximum size constraints which will be 
>> propagated correspondingly to the SwingNode and it's parent will honor those 
>> settings during layout.`
>> 
>> so the fix is to add the listener as soon as the component is added to the 
>> JLightweightFrame's content.
>
> Prasanta Sadhukhan has updated the pull request incrementally with one 
> additional commit since the last revision:
> 
>   Register listener before component add

I think OOME is expected.  The earlier stack trace was for retina (scale=2), 
when displaying on a secondary monitor with the scale=1 I am getting OOME later:


Button size: java.awt.Dimension[width=13184,height=3712]
SwingNode size: 13184.0 3712.0
Exception in thread "AWT-EventQueue-0" java.lang.OutOfMemoryError: Java heap 
space

~48M * 4 bytes (I assume) = 193Mbytes.

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

PR Comment: https://git.openjdk.org/jdk/pull/15960#issuecomment-1749497333

Reply via email to