Search code examples
javamethodsjavafxrights

JAVAFX - Windows rights calling


I have two good working windows (main window, first window) in seperate .java files, at the same package.

The program handles, if I call the the First window (from the main), the Main stays in the background. The only problem is that I still can use the main window if I click there, and create infinity first windows.

One solution is to shut down the Main window, to avoid clicking there again, but I would like to keep there. In order to make the solution I need a code which makes the background window somehow disabled until I click something in the First Window. But to do that I need to give the rights to the "handler.java" to operate with the main.

Anybody has any idea how to do that?

Let me show you the 2 java file's methods:

Main.java:

  public class program extends Application {

@Override
public void start(Stage main) throws Exception {
    Parent root = FXMLLoader.load(getClass().getResource("mainwindow.fxml"));
    Scene scene = new Scene(root);

    main.setScene(scene);
    main.setTitle("Main);
    main.setWidth(800);
    main.setHeight(600);
    main.setResizable(false);

          main.show();

First.java

    public void first() throws Exception {
    Parent root = FXMLLoader.load(getClass().getResource("first.fxml"));
    Scene scene = new Scene(root);
    Stage first = new Stage();     
    first.setScene (scene);
    first.setTitle("Köszöntjük az Útiokosban!");
    first.setWidth(400);
    first.setHeight(200);
    first.setResizable(false);

          first.show();

}

Solution

  • Try using the advisory in the chapter "Modality" in this link: http://docs.oracle.com/javase/8/javafx/api/javafx/stage/Stage.html