8

HBox の Elements を大きくすることができなかったので、次のサンプル コードをjava2s.comからダウンロードしました。これは、最小限の機能しない例として機能します。

package fxtest;

import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Priority;
import javafx.scene.paint.Color;
import javafx.stage.Stage;

public class Fxtest extends Application {
    public static void main(String[] args) {
        Application.launch(args);
    }

    @Override
    public void start(Stage primaryStage) {
        primaryStage.setTitle("");
        Group root = new Group();
        Scene scene = new Scene(root, 600, 250, Color.WHITE);

        HBox hbox = new HBox();
        TextField field = new TextField();
        HBox.setHgrow(field, Priority.ALWAYS);
        hbox.getChildren().addAll(new Label("Search:"), field, new Button("Go"));


        root.getChildren().add(hbox);
        primaryStage.setScene(scene);
        primaryStage.show();
    }
}

結果は次のようになります

私の理解が正しければ、TextField は大きくなるはずですよね。

私のJavaバージョンは1.7.0_51です

私の JavaFX バージョンは 2.2.51-b13 です

なぜ機能しないのか/私がしなければならないことを知っていますか? ありがとう!

4

2 に答える 2

4

jewelsea は、与えられた例に対して正しい答えを提供しました。ありがとうございます!

これは、同様の症状であるが別のルートの問題を突き止めるのに役立ちました。ScrollPanes を使用する場合は、設定する必要があります

    scrollPane.setFitToHeight(true);
    scrollPane.setFitToWidth(true);

望ましい成長効果を得るために。

于 2014-02-19T12:25:09.420 に答える