调整窗口大小时调整对象大小

时间:2018-03-25 11:33:18

标签: java javafx javafx-8

我想知道如何在调整窗口大小时让我的盒子和所有元素在屏幕上增长/缩小。

package view;

import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.control.Label;
import javafx.scene.control.Tab;
import javafx.scene.control.TabPane;
import javafx.scene.control.TabPane.TabClosingPolicy;
import javafx.scene.control.TextField;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.scene.shape.Ellipse;

//You may change this class to extend another type if you wish
public class ModuleChooserRootPane extends BorderPane {

    private ButtonPane bp;
    private ProfileCreator profileCreator;
    private Tab tab1, tab2;


    public ModuleChooserRootPane() {

        //This sets the colour of background
        this.setStyle("-fx-background-color: #EDF1F3;");

        //Creating the tabs here
        TabPane tabPane = new TabPane();
        tabPane.setTabClosingPolicy(TabClosingPolicy.UNAVAILABLE);
        setTop(tabPane);
        tab1 = new Tab("profile");

        //Creates a new instance of the buttonPane (Used from ButtonPane.java) and ProfileCreator
        bp = new ButtonPane();
        profileCreator = new ProfileCreator();

        //This adds the padding on the left so that "submit" button is in line with text fields
        bp.setPadding(new Insets(0, 0, 0, 120));

        //Creates a new VBox which adds the ProfileCreator and the button pane
        VBox rootContainer = new VBox(profileCreator, bp);
        rootContainer.setPadding(new Insets(100,100,100,100));
        setCenter(rootContainer);

        tab1.setContent(rootContainer);
        tabPane.getTabs().addAll(tab1);

    }

}

目前,如果调整窗口大小,所有盒装和按钮只会停留在同一个位置而不会移动

0 个答案:

没有答案