4

2つの質問があります

1. javafx アプリケーションで、子 (crosshairArea) を親の左上隅に配置し、幅と高さも 1/2 にしたいと考えています。親関数「layoutChildren」(VBox)をオーバーライドすることでそれができると思いますが、それを行う他の方法はありますか? 例えばプロパティバインディング?

2.最初、VBox はシーン全体を占有しますが、シーンの半分の下部に移動 (再配置) するにはどうすればよいですか?

public class Crossh extends Application {

    public static void main(String[] args) {
        launch(args);
    }

    @Override
    public void start(Stage stage) {        
        VBox root = new VBox(5);
        // root.setPadding(new Insets(20,20,20,20));
        root.setStyle("-fx-border-color:red");

        Pane crosshairArea = new Pane();
        crosshairArea.maxWidthProperty().bind(root.widthProperty());
        crosshairArea.setStyle("-fx-border-color:black");       

        root.getChildren().add(crosshairArea);
        Scene scene = new Scene(root);
        stage.setScene(scene);
        stage.setTitle("Location Crosshair");
        stage.setWidth(900);
        stage.setHeight(700);        
        stage.show();
    }
}
4

2 に答える 2