JFXPanel ignores size change of root node

Werner Lehmann lehmann at media-interactive.de
Mon Dec 17 11:09:01 PST 2012


Artem,

On 17.12.2012 13:49, Artem Ananiev wrote:
> At the API level we have code that calculates Scene's preferred size and
> resize Stage so it perfectly matches this Scene. It's only done a) when
> the window is being shown b) if the window size was not set explicitly.
> This code can be extracted into a public method to be called by
> application at arbitrary moment, close to AWT's Frame.pack().
>
> Jasper, Richard, what do you think about this idea?

I suggest to clarify this in the JFXPanel javadoc. Even with your 
comment in RT-13758...

> As for manual/automatic resizing, it's controlled by AWT/Swing
> LayoutManager. If you or your LayoutManager set JFXPanel size
> explicitly, FX scene is forced to that size, it's a kind of manual
> mode. Automatic mode is for window managers that take component's
> preferred size into consideration (e.g. FlowLayout).

...I had no clue that "automatic mode" refers to initial scene sizing only.

Having a method to do this sizing on demand would be nice but I guess 
most people needing this would observe the root node's size anyway and 
then demand a JFXPanel update when it changes. Also, Group already has a 
boolean property autoSizeChildren (true by default it seems). It would 
be nice to have something like this on the JFXPanel as well.

> invalidate(), as well as JComponent.revalidate(), is thread safe.

Recently we've been burned by deadlocks on Mac: one thread would hold a 
treelock and wait for some other lock in native Mac code. The other 
thread vice versa. Admittedly we were doing evil things, like AWT 
force-painting an FX node (or changing the mouse cursor to hourglass) 
while the EDT is blocked but still... ;-)

> In general, it looks like a bug, we shouldn't depend on the timings.
> Please, file a new bug to JavaFX JIRA, but I can't guarantee it will be
> fixed in a few hours :)

Well, I'd take a fix for 2.2.6 as well :)  Currently resetting the 
scene, waiting 50ms, then invalidating seems to work. On my machine at 
least. Filed bug RT-27053.

Rgds
Werner



More information about the openjfx-dev mailing list