[API Review] RT-27887: introduce a node to embed Swing into JavaFX

Anthony Petrov anthony.petrov at oracle.com
Fri Jan 25 02:48:57 PST 2013

On 1/25/2013 14:28, Mario Torre wrote:
> I have some doubt regarding setContent:
> * Attaches a JComponent instance to display in this SwingNode.
> * The method can be called either on the event dispatch thread or the
> * JavaFX application thread.
> The only way this method can be called by both threads and work is that
> you call yourself SwingUtilities.invokeLater inside it.
> I wonder if it's not better to require that the method is called
> *always* in the swing thread to avoid confusion, I fear that some
> programmers will construct their swing components outside the EDT, but
> even worse, I fear this can be taken as some kind of allowance to
> initialise them, and perhaps in some cases even start them, in the FX
> dispatching thread.
> For no reason this consideration should pollute the API, but I guess
> either requiring that the method is called in the EDT or putting in the
> JavaDoc that the Swing components still need to follow the usual rules
> would be a better thing.

+1. I think that we should be very specific regarding the threading 
contract for this API, and the contract must be clearly stated in the 

> Also, the API suggest no heavyweight component, does it means menues and
> tooltip can't be used?

Menus and tooltips are separate top-level windows, they are not part of 
the hierarchy of components that are showing the tooltip or the menu. So 
there should not be any problems with heavyweight popups wrt. the API.

best regards,

More information about the openjfx-dev mailing list