2013-07-06 35 views
0

我想知道是否有可能在我的主Group Panel包裝在其他類型的面板?其實我可以用代碼做到這一點,但我只想從場景構建器處理它,以更輕鬆地安排組件。例如,你可以看到一個簡單的代碼部分,我如何設法將我的主Group Panel包裝在Boder Pane中。是否可以在Scene Builder的其他類型面板中包裝Group Panel?

// My main panel which initialized automatically to Group Panel 
rootPane = FXMLLoader.load(getClass().getResource("Risk3.fxml")); 

FlowPane flowPane = new FlowPane(); 

//Text Box 1 
TextArea countryInfoText = new TextArea(); 
countryInfoText.setPrefWidth(100.0); 
countryInfoText.maxWidth(100.0); 

flowPane.getChildren().add(countryInfoText); 
flowPane.setPrefWidth(countryInfoText.getPrefWidth()); 

BorderPane borderPane = new BorderPane(); 
borderPane.setCenter(rootPane); 
borderPane.setLeft(flowPane); 

scene = new Scene(borderPane); 

primaryStage.setScene(scene); 
primaryStage.show(); 

但場景生成器犯規讓我把這個包root(或組面板換句話說)在其他面板中。作爲示例,您可以看到下面的快照。

enter image description here

希望我已經清楚我和你會明白很多關於每個響應。無論如何,謝謝。

回答

0

好男人我做到了。訣竅是你必須用更改fxml文件的源代碼來包裝面板。所以我包括該行

<BorderPane id="BorderPaneDocument" fx:id="mainPanel" xmlns:fx="http://javafx.com/fxml" fx:controller="javafxapplication1.RiskControllerClass"> 
    <center> 
<Group> 
. 
. 
</Group> 
</center> 
</BorderPane> 

哪個組是我想要包裝在BorderPane中的主面板。所以我在fxml文件中創建了一個Border Panel,並將組面板放在Border Pane的中心。它可以完美地使用這種方式,而且我可以從場景構建器中修改每個部分。

相關問題