0
首先,我是Java的初學者。我正在嘗試用JavaFX在Java中創建一個大富翁遊戲。我在Gridpane中繪製了該板。JavaFX將Gridpane放入BorderPane
我給你們的問題是如何將GridPane放在BorderPane的中心。 Atm Gridpane佔據整個屏幕。我希望它位於邊框的中心,並使用其他空間來顯示菜單和其他窗格。
的GridPane
public class BordView extends GridPane {
private GridPane spelbord = new GridPane();
public BordView() {
initNodes();
layoutNodes();
}
private void initNodes(){
}
private void layoutNodes(){
RowConstraints rowsEdge = new RowConstraints();
rowsEdge.setPercentHeight(14);
RowConstraints rowsMid = new RowConstraints();
rowsMid.setPercentHeight(8);
ColumnConstraints colEdge = new ColumnConstraints();
colEdge.setPercentWidth(14);
ColumnConstraints colMid = new ColumnConstraints();
colMid.setPercentWidth(8);
this.getColumnConstraints().addAll(colEdge, colMid,
colMid, colMid, colMid, colMid, colMid, colMid, colMid, colMid, colEdge);
this.getRowConstraints().addAll(rowsEdge, rowsMid,
rowsMid, rowsMid, rowsMid, rowsMid, rowsMid, rowsMid, rowsMid, rowsMid, rowsEdge);
this.setGridLinesVisible(true);
}
的BorderPane
public class GameView extends BorderPane {
BorderPane borderpane = new BorderPane();
public GameView() {
layoutNodes();
}
private void layoutNodes() {
borderpane.setCenter(BordView);
}
複製並粘貼問題中的代碼比鏈接到代碼圖片要好得多。 – lfurini