0

I'm having issues with FXML loading with my project members who are running mac os. I'm fairly new to the whole JavaFX loading process within java code but this is how my code is set out at the moment. The class is called ControlPanel.java, the fxml is controlPanel.fxml, it contains onAction# methods and I'm using the ControlPanel.java as the controller for these methods. It works completely fine on windows operating systems but when we try to run it in eclipse it opens but doesn't display anything. Just wondering if i'm doing anything wrong. I defined the controller within the document at the top level which is an anchorPane fx:controller="project.fx.ControlPanel"

public static void main(String[] args) {
    Application.launch(ControlPanel.class, (java.lang.String[])null);
}

@Override
public void start(Stage primaryStage) {
    try {

        Parent page = (Parent) FXMLLoader.load(getClass().getResource("controlPanel.fxml"), null, new JavaFXBuilderFactory());

        Scene scene = new Scene(page);
        primaryStage.initStyle(StageStyle.TRANSPARENT);
        primaryStage.setScene(scene);
        primaryStage.show();
    } catch (Exception ex) {
        Logger.getLogger(ControlPanel.class.getName()).log(Level.SEVERE, null, ex);
    }

}

@FXML
protected void doSomething() {
    System.out.println("Done something");
}

1 Answer 1

1

First of all you are creating a 2nd instance of ControlPanel (1st ist created through Application.launch()). So you should set the controller instance or use a different class as the control.

We'd need to see more code to tell why it does not work on Mac but on Windows

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.