Embedding Mac native widgets into a Scene

Stephen F Northover steve.x.northover at oracle.com
Fri Oct 31 14:52:58 UTC 2014

Hi Mike,

Embedding native controls in FX runs afoul of the whole 
lightweight/heavyweight issue.  I had a hack of this once using SWT 
native controls and I was able to have them appear on Windows because 
HWND clipping was honored but on Mac, FX drew on top of the native 
control.  Mac was changed to use CALayers way back for JDK7 and this 
also made things more complicated.

Having said all that (from memory), for iOS, there was some work that 
overlayed an iOS text control in order to use the native keyboard 
control.  The control was created when editing started and then disposed 
when editing ended.  This would obviously have the same 
lightweight/heavyweight issues while editing was happening and a host of 
other smaller problems (wrong font, jumping, scrolling etc).

One possible way for this to really work would be to get the native 
control to render to a texture and get JavaFX to draw the texture. That 
is just the painting side of the equation.  Events would need to be 
delivered to this non-painting control as well.  There are operating 
system calls on Mac that you can use to paint a control to an image so 
it is in theory doable but a ton of work.


On 2014-10-31, 9:48 AM, Mike Hearn wrote:
> JavaFX provides a great set of widgets that are pretty complete, but a few
> lag behind behind their native counterparts on some platforms. This is
> especially noticeable with the Mac text field widget, which has things like
> integrated spelling/grammar checking, auto correct, services, speech
> recognition and so on.
> WebKit manages to expose all this functionality despite that HTML is not
> the native Mac UI framework. So I am wondering how hard it is for JFX to do
> the same. However, I know very little about how WebKit does this or how
> easy it'd be to replicate in the Java world. Are there any experts on the
> list who could comment?

More information about the openjfx-dev mailing list