2014-10-31 8 views
1

에 새로운 레이아웃을 추가 나는 내 부모 레이아웃을 설정하는 다음과 같은 코드가 있습니다자바 FX 부모 레이아웃

public void start(Stage primaryStage) { 
    try { 
     Parent root = FXMLLoader.load(getClass().getResource("/view/BaseStructure.fxml")); 
     Scene scene = new Scene(root); 
     scene.getStylesheets().add(getClass().getResource("application.css").toExternalForm()); 
     primaryStage.setScene(scene); 
     primaryStage.show(); 
    } catch(Exception e) { 
     e.printStackTrace(); 
    } 
} 

내가 부모 레이아웃의 right에 다른 레이아웃을 추가 할 수 있습니다. 메인 클래스에서 어떻게 할 수 있습니까?

는이 같은 .fxml 파일이 어떻게 생겼는지 내 부모 레이아웃입니다 : 당신은 두 개의 레이아웃을 래핑 선택한 다른 레이아웃을 사용할 수 있습니다

<VBox prefHeight="400.0" prefWidth="640.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="application.Main"> 
    //more code here 
    <right> 
    //need my second layout here 
    </right> 
</VBox> 

답변

1

당신은 :

HBox hbox = new HBox(10); 
hbox.getChildren().addAll(getMySecondLayout(), root); 
Scene scene = new Scene(hbox); 

는 또한 모든 GUI를 재 설계 할 수 BorderPane, AnchorPane 등과 같은 다른 레이아웃을 사용하십시오.