Windows resize while dragging

224 Views Asked by At

My application is an Horizontal Flow SplitPane in an AnchorPane. On the right side of the SplitPane I can plot windows by left click on a button.

I can also arrange these windows horizontally or vertically to fit the parent container prefSize, and it all works fine.

enter image description here

My issue is about how to auto-resize windows when I resize the GUI because if I click and drag on the rightmost pane I get this effect.

enter image description here

So, my question is: how to bind the windows to autoresize itself when narrow or widen the GUI?

Thanks all

Edit: here is how I arrange windows vertically

@FXML
private void windowsArrangeVertically(ActionEvent event) {
    // tutto il contenuto del tab, compreso il gruppo
    Group gp = (Group) tabpaneWorkspace.getSelectionModel().getSelectedItem().getContent();

    int itemsInTab = gp.getChildren().size();// dimensione del contenuto del tab, gruppo compreso
    int totWindows = 0;
    Window winItem;

    // voglio sapere quante sono le window presente nel tab, escludendo il gruppo
    for(int i=0; i<itemsInTab; i++){
        if(gp.getChildren().get(i) instanceof Window){
            totWindows++;
        }
    }
    // mi serve per riposizionare le finestre sulle x
    double x = 0;

    for(int i=0; i<itemsInTab; i++){
        // se il contenuto del tab è un istanza di window
        if(gp.getChildren().get(i) instanceof Window){
            // allora scorri tutto il contenuto uno per uno
            winItem = (Window)gp.getChildren().get(i);
            // determina la larghezza della finestra in base al num di windows presenti
            double tabWidth = tabpaneWorkspace.getWidth()/totWindows;
            // e assegna la larghezza
            winItem.setPrefSize(tabWidth , tabpaneWorkspace.getHeight()-31);             
            winItem.setLayoutX(x);
            winItem.setLayoutY(0);
            x += tabWidth;
        }
    };
}
0

There are 0 best solutions below