Adil Adil - 1 year ago 319
Java Question

RequestFocus in TextField doesn't work -JavaFX 2.1

I'm using JavaFX 2.1 and I'have created GUI using FXML, in the controller of this GUI I have added

, but always I get the focus in the first button that I have added to the GUI. I'm using Scene Builder 1.0.

Answer Source

At the time of initialize() controls are not yet ready to handle focus.

You can try next trick:

public void initialize(URL url, ResourceBundle rb) {
    Platform.runLater(new Runnable() {
        public void run() {
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download