Opening frame that is under the JavaFX program category

51 Views Asked by At

Most of program is using JFrames throughout the application for all the different windows that can appear. However, I have to play an instructional video for the user inside a JFrame. I couldn't find a way to do this, so I had to make a JavaFX program. Is there a way to get directly from one of my JFrames to the JavaFX window?

I've been using syntax like this to open up other JFrame:

                dispose();
                paths pths = new paths();
                pths.setVisible(true);

However, when trying to open up the JavaFX using the above code, I get errors. I also can't create a new JavaFX inside an already existing project.

1

There are 1 best solutions below

0
On BEST ANSWER

I am not sure to understand your problem but in order to create a new frame in JavaFX. You have to create a new class with a new stage. Let's say you create a new class "newFrame" with the code below.

public void show(Stage stage){
   //define your root
   double width = 200;
   double height = 200;
   Scene scene = new Scene(root, width , height);
   stage.show();
}

You can show the new frame by using :

newFrame NT = new newFrame();
NT.show();