Cannot see JFXPanels on modal JDialog

Werner Lehmann lehmann at media-interactive.de
Fri Aug 10 08:42:20 PDT 2012


On 10.08.2012 17:32, Artem Ananiev wrote:
> I wonder why it was not reproducible with a simple test case then...

I guess it would have. Of course, in that case I needed to know the 
exact problem first so that I could reproduce it :)

My test case showed a modal JDialog from a JButton in a JFrame. The 
dialog has an fx panel and it worked. In my application I was showing a 
JDialog from an fx panel inside a JFrame. That's where I missed the 
Platform.runLater.

This was actually the first time I tripped about this kind of problem 
but the code is not really pretty. In some cases I have two or even 
three nested runnables to go from swing to fx back to swing etc. The 
subtle delays that I am getting because of this are also bad for 
layouting, e.g. swing starts layouting before fx asynchronously finished 
its initialization.

Actually, I just lost over an hour trying to work around such a problem 
without success in the end:
1. JDialog
2. add fx panel
3. init fx panel in runLater (adds two buttons to an HBox)
4. show dialog
5. dialog displays fx panel clipped (bottom half of buttons is missing)

Apparently the fx initialization finishes after swing is done with 
layouting, and afterwards there is no relayouting. And I tried a lot of 
stuff with requestLayout, layoutChildren, revalidate etc pp.

Werner


More information about the openjfx-dev mailing list