Selection Events v. Focus Events - order is broken in JavaFX 8?

Scott Palmer swpalmer at
Tue Feb 10 16:11:13 UTC 2015

When I say "commit" I mean my formatted field sets it's 'value' property
based on the conversion from the 'text'.  A binding to its value property
takes care of updating the table item.
The field itself has no business knowing about the table selection changes.

For now I'm subclassing the control so I can force a commit in my selection
listener before the control gets bound to the newly selected item.  So
basically I am working around it as you suggest. But the control is
intended to be more generic.  It only knows to update its value property on
focus lost or enter pressed.


On Tue, Feb 10, 2015 at 10:47 AM, Tomas Mikula <tomas.mikula at>

> Hi Scott,
> whether that behavior is a bug in JavaFX 8 or not, why not commit on
> focus lost *or* selection change? Less assumptions means more robust
> code.
> Regards,
> Tomas
> On Tue, Feb 10, 2015 at 10:15 AM, Scott Palmer <swpalmer at> wrote:
> > I have a custom field (my own formatted field done in JavaFX 2.2) bound
> to
> > a property of the selected row in a TableView. My control commits an edit
> > on focus lost.
> >
> > This works on JavaFX 2.2 but fails on JavaFX 8.  After a bit of
> debugging I
> > discovered why. The way to reproduce the problem was to type something
> into
> > the field and then select a different row in the table.   With JavaFX 2.2
> > the edit is committed and then the control is populated with the data
> from
> > the new selection.  With JavaFX 8, the selection change event happens
> prior
> > to the focus lost event, so my control's data is replaced without being
> > committed.
> >
> > This smells like a rather serious bug in JavaFX 8.  The TableView
> selection
> > should not change as the result of a mouse click prior to the TableView
> > getting the focus (and thus my control losing the focus and committing
> the
> > edit to the selected item before the selection changes).
> >
> > Do you agree that this is broken behavior?
> > Do you have an idea of how to work around it?
> >
> > Regards,
> >
> > Scott

More information about the openjfx-dev mailing list