How to adjust windows to the .fxml that is opening?

0

Well, what I want to do is that when I click on a certain button, it sends me to another window, well that's what it does, what happens is that I want that window to measure more than the main window (re-size its size) ).

Method that sends me to the screen that I want to resize

public void Ayuda() throws IOException {
        FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("../Vista/Login/Ayuda.fxml"));
          Pane cmdPane = (Pane) fxmlLoader.load();
          cmdPane.maxHeight(1000);
          cmdPane.maxWidth(900);
          try {
              content.getChildren().clear();
              content.getChildren().add(cmdPane);
              } catch (Exception e) {
              e.printStackTrace();
              } 

Initial class that loads the login

public class Main extends Application {
    @Override
    public void start(Stage primaryStage) {
        try {
            Parent root = FXMLLoader.load(getClass().getResource("../Vista/Login/Login.fxml"));
            Scene scene = new Scene(root);
            primaryStage.setScene(scene);
            primaryStage.show();
            primaryStage.setMinHeight(502);
            primaryStage.setMinWidth(610);
            primaryStage.setMaxWidth(610);        
            primaryStage.setMaxHeight(502);
        } catch(Exception e) {
            e.printStackTrace();
        }
    }

So the screen that should be made bigger appears

Note: There should be space between the final buttons and the edge of the window

    
asked by David 03.11.2016 в 19:17
source

2 answers

1

Simply, open your fxml with scene builder and modify the dimensions of the anchor pane you want. Then in the method that opens the window you should implement a code like that.

The controller should be changed by your controller, which handles your fxml file, in my case it is FXMLControllerPrincipal Screen.

Parent root = FXMLLoader.load(FXMLControllerPantallaPrincipal.class.getResource("FXMLLogin.fxml"));
Scene scene = new Scene(root);
stage.setScene(scene);
stage.show();
    
answered by 30.01.2018 в 13:25
0

Try setting the minimum size of your new window.

 cmdPane.minHeight(X);
 cmdPane.minWidth(Y);
    
answered by 10.11.2016 в 11:54