1

I have read several questions/solutions here that are related to my problems. but nothing seems to work.

so I have a primarystage in fullscreen mode, say if i click a button it changes the scene. but the stage seems to display the taskbar. also I resolved the issue by adding this to all of the scene methods..

stage.setFullScreen(false);
        stage.setFullScreen(true);

BUT, the transition in scenes is not that fluid. first it goes to desktop and back to fullscreen.. which is not the ideal solution.

here is my code for the primary stage:

 public static Stage stage;
private static AnchorPane mainLayout;

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

        Main.stage = primaryStage;
        Main.stage.setTitle("Raven App");
        stage.initStyle(StageStyle.UNDECORATED);
        stage.setFullScreen(true);
        stage.setFullScreenExitKeyCombination(KeyCombination.NO_MATCH);
        Main.showMain();

    }

here is my code for changing the scene:

   public static void UserLogin() throws IOException
{



        FXMLLoader loader=new FXMLLoader();
        loader.setLocation(Main.class.getResource("page/UserHomeLogin.fxml"));
        mainLayout=loader.load();
        Scene scene=new Scene(mainLayout);
        stage.setScene(scene);
        stage.show();


    } 

I don't know if this is a bug or something. But i thought if you set your primary stage to full screen. and should be fullscreen all through out regardless of scene.

also, if i have a primary stage in full screen mode.. and a secondary stage NOT in full screen mode. the primary stage seems to disappear if i click a button to show the secondary stage. I wanted to show the secondary page on top of the primary stage, and the primary stage should not be clickable unless the secondary page is closed.

my code for showing the secondary stage:

 public static void PasswordVerify() throws IOException
{


Stage stage = new Stage();
Parent root = FXMLLoader.load(Main.class.getResource("page/PassConfirm.fxml"));
stage.setScene(new Scene(root));
stage.setTitle("popup window");
stage.initModality(Modality.APPLICATION_MODAL);
stage.showAndWait();
stage.show();


    }
  • I apologize, as i am not really familiar with changing the root node. I made individual fxmls in scene builder and considered them as scenes.. fxml for user, fxml for admin.. etc. – Andres Magallanes Mar 11 '18 at 18:56

1 Answers1

3

Instead of creating a new scene, just change the root of the existing scene:

public static void UserLogin() throws IOException {
    FXMLLoader loader=new FXMLLoader();
    loader.setLocation(Main.class.getResource("page/UserHomeLogin.fxml"));
    mainLayout=loader.load();
    stage.getScene().setRoot(mainLayout);
    // or just 
    // scene.setRoot(mainLayout);
    // if you already have a reference to the scene
} 

The second thing you are asking is not really possible. In JavaFX, on many platforms "full screen mode" is really implemented as "exclusive screen mode"; so there is a unique window visible. So you would need another solution entirely to this, that didn't involve displaying a new window at all.

James_D
  • 201,275
  • 16
  • 291
  • 322
  • that is a very quick response.. Thank you so much. it now runs perfectly fine, Thanks to your code. For the second problem, thank you for letting me know, maybe I'll just create a pane that will appear and make the other pane disabled. Sorry for my english. – Andres Magallanes Mar 11 '18 at 19:02
  • @AndresMagallanes Yes, creating some other pane and making it appear on top of the current content is kind of what I had in mind; it might not be the easiest or cleanest solution, but should be possible. – James_D Mar 11 '18 at 19:04
  • @AndresMagallanes if this answer solved your problem, accept it as the correct answer. – SedJ601 Mar 11 '18 at 19:30