2017-04-04 5 views
0

現在、グリッドペインは、ウィンドウのサイズが変更されている間、X軸の中央にとどまりますが、どうすればY軸の中央に配置することができますか?あなたは、コードのいくつかの種類を追加する必要がウィンドウがリサイズされている間、GridPaneは中央にとどまる

GridPane grid = new GridPane(); 
    grid.setPadding(new Insets(20, 0, 0, 0)); 
    grid.setAlignment(Pos.CENTER); 
    grid.setHgap(20); 
    grid.setVgap(20); 

    this.setContent(grid); 
+0

です:

私はTabPaneのタブでこれを持っていますあなたが何をしているのか、それをどう行っているのかを見ることができます。 – Sedrick

+0

@SedrickJeffersonコード –

+0

を追加しました。特定の回答が必要な場合は、ビューの完全なコードを追加する必要があります。 – Sedrick

答えて

0

鍵はここにVBox.setVgrow(tabPane, Priority.ALWAYS);

import javafx.application.Application; 
import javafx.scene.Scene; 
import javafx.scene.control.MenuBar; 
import javafx.scene.control.TabPane; 
import javafx.scene.layout.Priority; 
import javafx.scene.layout.VBox; 
import javafx.stage.Stage; 

/** 
* 
* @author blj0011 
*/ 
public class JavaFXApplication65 extends Application 
{ 

    @Override 
    public void start(Stage primaryStage) 
    { 
     VBox root = new VBox(); 
     MenuBar mb = new MenuBar(); 

     TabPane tabPane = new TabPane(); 
     root.getChildren().addAll(mb, tabPane); 


     //StackPane stackPane = new StackPane(); 
     CreateProfilePane cp = new CreateProfilePane(); 
     tabPane.getTabs().add(cp); 
     VBox.setVgrow(tabPane, Priority.ALWAYS); 



     Scene scene = new Scene(root, 300, 250); 

     primaryStage.setTitle("Hello World!"); 
     primaryStage.setScene(scene); 
     primaryStage.show(); 
    } 

    /** 
    * @param args the command line arguments 
    */ 
    public static void main(String[] args) 
    { 
     launch(args); 
    } 

} 

enter image description here

enter image description here

+0

私のStackPaneはタブ内にあり、グリッドはまだ集中化されていませんウィンドウのサイズが変更されたとき。その周りには道がありますか? @SedrickJefferson –

+0

[this](https://gyazo.com/642302a0d1ea63b779f8c638708393d3)のスクリーンショットを見ると、StackPaneは緑色で塗りつぶされています。 –

+0

はあなたのように見えます。vgow =常にスタックペインにあります。 – Sedrick

関連する問題