2016-11-17 1 views
1

BorderPane에 프로그래밍 방식으로 추가하고 제거하려는 사이드 메뉴. Node을 추가 할 때 문제가 발생하지만 표시되지 않습니다. BorderPaneStackPane은 FXML 파일에 정의되어 있습니다.JavaFX를 BorderPane에서 노드 추가 및 제거

나는 이런 식으로 뭔가를 할 :

StackPane temp = (StackPane) borderPane.getChildren().get(1); 
borderPane.getChildren().remove(1); 
borderPane.getChildren().add(0, temp); 

내가 borderPane.requestLayout()을 시도했지만이 작동하지 않습니다.

답변

0

당신은 현재 Node 할당을 검색 할 수 Node 다른 부분들도 getRight, getLeft, getTop, getBottom, getCenter을 추가 setRight 또는 setLeft, setTop, setBottom, setCenter 방법을 사용할 수 있습니다. set 메서드는 null 값을 전달하여 현재 설정된 Node을 제거하는 데에도 사용할 수 있습니다.

예 :

당신이 오른쪽에 배치 StackPane이있는 BorderPane을 상상해, 당신은 왼쪽으로 이동합니다.

StackPane temp = (StackPane) borderPane.getRight(); // Casting is unnecessary 
borderPane.setRight(null); 
borderPane.setLeft(temp); 
+0

감사합니다. –

+0

어떻게'borderPane.setAligment()'를 사용할 때 static을 사용하도록 권고 받았습니까? 그렇게하면 노드를 배치하는 것이 더 좋았을 것입니다. – Lealo