0

When i made my GUI by Scene builder it was working fine on eclipse and i save this. And i re-open eclipse then this error show.Whenever i created a new project and re-open eclipse / restart computer , it shows me this message every-time. And When i tried to open my FXML document is says "**

Open Operation has been failed.Make sure that Chosen file is a valid FXML Document

ClLICK HERE TO SEE THE ERROR MESSAGE -This is the message that FXML Document show me when i restart my computer. It show this for every-time for every project.

Please Help me Here is the Code

 package application;

public static void main(String[] args) {
     launch(args);
}

@Override
public void start(Stage primaryStage) throws Exception {

    Parent root = FXMLLoader.load(getClass().getResource("MyDocmnt.fxml"));
    Scene scene = new Scene(root);
    primaryStage.setTitle("My Tittle");
    primaryStage.setScene(scene);
    primaryStage.show();

}

CLICK HERE TO SEE THE ERROR - this is the error it show me on running the code

Clay
  • 4,700
  • 3
  • 33
  • 49
  • 2
    1. Please post the stack trace in the question, instead of posting a screen shot of it. 2. Please post the FXML code. – James_D Oct 21 '16 at 14:38
  • you probably need to specify the package the fxml is in. "/application/MyDocmnt.fxml" – Nevets17 Oct 21 '16 at 15:30
  • check this out https://stackoverflow.com/questions/40367275/scenebulider-not-able-to-open-fxml-file –  Mar 14 '18 at 19:55
  • See this. https://stackoverflow.com/questions/40367275/scenebulider-not-able-to-open-fxml-file it happened with me too. –  Mar 14 '18 at 19:57

2 Answers2

0

Try this:

package application;

import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.stage.Stage;
import javafx.scene.Parent;
import javafx.scene.Scene;

    public class Main extends Application {

                @Override
                public void start(Stage primaryStage) {
                    try {
                        Parent root = FXMLLoader.load(getClass().getResource("/application/MyDocmnt.fxml"));
                        Scene scene = new Scene(root);
                        primaryStage.setTitle("My Title");
                        primaryStage.setScene(scene);
                        primaryStage.show();
                    } catch(Exception e) {
                        e.printStackTrace();
                    }
                }

        public static void main(String[] args) {
             launch(args);
        }

    }
Nevets17
  • 109
  • 1
  • 9
0

javafx.application.Application class is an abstract class. And start() method is an abstract method of Application class.

In Java, we have to implement all the abstract methods of an abstract class when extending that abstract class. Here, we are implementing the abstract method (start() method) by overriding the start() method.

So, try this:

package application;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;

    public class Main extends Application{

            public static void main(String[] args) {
                 launch(args);
            }

            @Override
            public void start(Stage primaryStage) throws Exception {

                Parent root = FXMLLoader.load(getClass().getResource("MyDocmnt.fxml"));
                Scene scene = new Scene(root);
                primaryStage.setTitle("My Tittle");
                primaryStage.setScene(scene);
                primaryStage.show();

            } 
    }
alps_ren
  • 11
  • 2