Static property "buttonData" does not exist or is read-only

1k Views Asked by At

I'm having a problem with the ButtonBar in JavaFX8.

I have this part of code in an FXML file :

  <ButtonBar>
    <buttons>
      <Button text="Précédent" ButtonBar.buttonData="BACK_PREVIOUS" />
      <Button text="Suivant" ButtonBar.buttonData="NEXT_FORWARD" />
      <Button text="Importer un load" ButtonBar.buttonData="LEFT" />
    </buttons>
  </ButtonBar>

It all works fine in the SceneBuilder, but when I load it like this (launched in eclipse) :

    FXMLLoader loader = new FXMLLoader(
            this.getClass().getResource("LoadSelection.fxml")
            );

    Pane pane = loader.load();

    Scene scene = new Scene(pane);
    primaryStage.setScene(scene);
    primaryStage.show();

I have this Exception :

Caused by: com.sun.javafx.fxml.PropertyNotFoundException: Static property "buttonData" does not exist or is read-only.

Does anyone knows how to solve this?

Thanks

1

There are 1 best solutions below

0
On BEST ANSWER

Sorry I just found the error.

I had this import in the fxml file

<?import org.controlsfx.control.*?>
<?import javafx.scene.shape.*?>
<?import javafx.scene.text.*?>
<?import javafx.geometry.*?>
<?import javafx.scene.control.*?>
<?import java.lang.*?>
<?import javafx.scene.layout.*?>

And, as weird as it can be, when I added <?import javafx.scene.control.ButtonBar?> all worked fine.