0

画面にいくつかのものを表示したいのですが、どのレイアウト システムを使用すればよいかよくわかりません。

画面の右側から、幅 300px、画面の高さのコンテナーが必要です。

左のコンテナは、右のコンテナが配置された後、画面の残りの部分を埋めるだけです。

したがって、サイズ変更の優先度を持つ大きなコンテナと、幅 300px の別のコンテナです。

どうすればいいですか?

4

2 に答える 2

0

封じ込める

上図のレイアウトを生成するサンプル コード

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.*;
import javafx.stage.Stage;

/**
 * Creates a full screen display with two containers.
 * The right container is fixed to 300 pixels wide.
 * The left container fills the remaining available space.
 */
public class ContainerSample extends Application {
    @Override public void start(final Stage stage) throws Exception {
        // create a resizable pane.
        final StackPane left = new StackPane();
        left.setStyle("-fx-background-color: lightblue;");
        left.setPrefWidth(500);

        // create a pane with a 300 pixel fixed width.
        final StackPane right = new StackPane();
        right.setStyle("-fx-background-color: palegreen;");
        right.setPrefWidth(300);
        right.setMinWidth(StackPane.USE_PREF_SIZE);
        right.setMaxWidth(StackPane.USE_PREF_SIZE);

        // layout the left and right pane.
        final HBox layout = new HBox(left, right);

        // grow the left pane width to fill available space.
        HBox.setHgrow(left, Priority.ALWAYS);

        // exit the application on mouse click.
        layout.setOnMouseClicked(event -> stage.hide());

        // uncomment to disallow exiting the full screen mode.
        //stage.setFullScreenExitHint("");
        //stage.setFullScreenExitKeyCombination(KeyCombination.NO_MATCH);

        // display the main application screen in full screen mode.
        stage.setFullScreen(true);
        stage.setScene(new Scene(layout));
        stage.show();
    }

    public static void main(String[] args) {
        Application.launch(args);
    }
} 
于 2014-05-05T18:17:02.163 に答える