chrisR chrisR - 1 year ago 107
Java Question

Java FX (FXML) setDisable

I have 2 buttons, one of them is Play, 2nd is Stop. If i click on Play he should be disabled and Stop should be enabled. I'm using Java FX ScreeBuilder 1.0 Why it doesn't work?

package javafxapplication1;

import java.util.ResourceBundle;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Label;
import javafx.scene.paint.Stop;
import javax.swing.JButton;
import javax.swing.plaf.basic.BasicOptionPaneUI;
import javafx.scene.control.Button;

* @author Admin
public class FXMLDocumentController implements Initializable {
private Button start;

private Button stop;

private void ButtonStart(ActionEvent event) {

private void ButtonStop(ActionEvent event) {

public void initialize(URL url, ResourceBundle rb) {


Answer Source

Make sure that you have the Button entry in the corresponding .fxml file linked with the method in your controller.

In your case, these entries should look similar the following:

<Button fx:id="start" onAction="#ButtonStart" />
<Button fx:id="stop" onAction="#ButtonStop" />
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download