Reputation: 108
I have JFXPanel with a textbox and few buttons on it. I want to lost focus of textbox if user click on anywhere other than child controls.
Upvotes: 1
Views: 156
Reputation: 108
Here is my working example:
override the mouse click event of JFXPanel as follows:
jfxPanel.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if(!toolbarJFX.getScene().getFocusOwner().isPressed()) {
toolbarJFX.getScene().getRoot().requestFocus();
}
}
});
Upvotes: 1