0

Every time I try to launch this it gives me 'location is required' in the Eclipse console relating to line 17, the one containing the FXMLLoader.

public class Main extends Application {
@Override
public void start(Stage primaryStage) {
     try {
            StackPane page = new StackPane();
            page = FXMLLoader.load(Main.class.getResource("Sample.fxml"));
            Scene scene = new Scene(page);
            primaryStage.setScene(scene);
            primaryStage.setTitle("First JavaFX programme.");
            primaryStage.show();
        } catch (Exception ex) {
            Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
        }

}

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

}

user3822332
  • 199
  • 3
  • 15

1 Answers1

0

First of all you need to make sure that Sample.fxml is in a resources directory. I think the answer to your question already exists here

Community
  • 1
  • 1
mremne21
  • 46
  • 2