第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

網(wǎng)格窗格中的 JavaFX 1 第一列比其他列間隔得更遠(yuǎn)

網(wǎng)格窗格中的 JavaFX 1 第一列比其他列間隔得更遠(yuǎn)

BIG陽 2021-09-03 14:43:34
在我的程序中,我嘗試將一個(gè)填充了 CheckBox 的 HBox 輸出到屏幕上。但是,當(dāng)我運(yùn)行該程序時(shí),與其他復(fù)選框相比,CheckBox "A" 的間距要大得多。這是我的代碼:private Scene assets (Stage primaryStage){        GridPane gp = new GridPane();        gp.setVgap(5);        gp.setPadding(new Insets(25, 25, 25, 25));        Text title = new Text("Assets");        title.setFont(Font.font("Arial", FontWeight.BOLD, 14));        gp.add(title, 0, 0);        Text description = new Text("Please select all assets you would like to include in your budget");        gp.add(description, 0, 1);        String [] optionsString = new String []{"A", "B", "C", "D", "E", "F"};        for (int i = 0; i < optionsString.length; i++) {            final int column = i;            final int row = i;            String option = optionsString[i];            CheckBox checkBox = new CheckBox(option);            HBox checkboxContainer = new HBox(checkBox);            checkboxContainer.setSpacing(20);            ChoiceBox<Integer> choice = new ChoiceBox<>();            Label label = new Label("How many " + optionsString[i] + " options do you have?");            choice.getItems().addAll(1, 2, 3, 4, 5);            HBox choiceContainer = new HBox(label, choice);            checkBox.selectedProperty().addListener((o, oldValue, newValue) -> {                if (newValue) {                    gp.add(choiceContainer, 0, row + 4);                } else {                    gp.getChildren().remove(choiceContainer);                }            });            gp.add(checkboxContainer, column, 3);        }        assets = new Scene (gp, 1280, 720);        return assets;    }編輯:這是我在說什么的截圖
查看完整描述

2 回答

?
拉莫斯之舞

TA貢獻(xiàn)1820條經(jīng)驗(yàn) 獲得超10個(gè)贊

private Scene assets(Stage primaryStage){

                Scene assets;

                GridPane gp = new GridPane();

                gp.setVgap(0);

                //gp.setPadding(new Insets(25, 0, 25, 25));


                Text title = new Text("Assets");

                title.setFont(Font.font("Arial", FontWeight.BOLD, 14));

                gp.add(title, 0, 0);


                Text description = new Text("Please select all assets you would like to include in your budget");

                gp.add(description, 0, 1);


                String [] optionsString = new String []{"A", "B", "C", "D", "E", "F"};

                HBox checkboxContainer = new HBox();

                checkboxContainer.setPadding(new Insets(5, 5, 5, 5));

                checkboxContainer.setSpacing(20);


                for (int i = 0; i < optionsString.length; i++) {

                    final int column = i;

                    final int row = i;

                    String option = optionsString[i];

                    CheckBox checkBox = new CheckBox(option);

                    ChoiceBox<Integer> choice = new ChoiceBox<>();

                    Label label = new Label("How many " + optionsString[i] + " options do you have?");

                    choice.getItems().addAll(1, 2, 3, 4, 5);


                    HBox choiceContainer = new HBox(label, choice);


                    checkBox.selectedProperty().addListener((o, oldValue, newValue) -> {

                        if (newValue) {

                            gp.add(choiceContainer, 0, row + 4);

                        } else {

                            gp.getChildren().remove(choiceContainer);

                        }

                    });

                    checkboxContainer.getChildren().add(checkBox);

                }

                gp.add(checkboxContainer, 0, 2);


                assets = new Scene (gp, 1280, 720);


                return assets;

            }

CheckboxContainer 必須在 for 循環(huán)之外。


查看完整回答
反對 回復(fù) 2021-09-03
?
GCT1015

TA貢獻(xiàn)1827條經(jīng)驗(yàn) 獲得超4個(gè)贊

您無意中將第 0 列(第一列)的寬度設(shè)置為文本的寬度,“請全選……等等”。

這是因?yàn)?GridPane 使用列的最大元素的首選寬度作為該列的寬度。

您可能希望從 GridPane 中刪除文本并將其作為 HBox 或 VBox 的一部分,而 GridPane 也是其中的一個(gè)元素。感覺這是最自然的解決方案。

要么是那樣,要么你將不得不在文本元素的跨度上胡鬧,所以 GridPane 認(rèn)為它應(yīng)該跨多個(gè)列。

GridPanes 最適合自然地可以被認(rèn)為是網(wǎng)格的數(shù)據(jù),其中每列的數(shù)據(jù)寬度相似。那不是你所擁有的。

然而,您可以強(qiáng)制 GridPane 通過一點(diǎn)點(diǎn)反復(fù)試驗(yàn)來做幾乎任何事情。


查看完整回答
反對 回復(fù) 2021-09-03
  • 2 回答
  • 0 關(guān)注
  • 162 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號