2013-03-10 5 views
6

어떻게 전체 SplitPane의 비례 크기 조정을 수행 할 수 있습니까?JavaFX - SplitPane, 크기 조정 및 비율

enter image description here

설정 디바이더는 내가 그들을 좋아하는 방법은 다음과 같습니다 :

public class JfxSplitPaneTest extends Application { 
    @Override 
    public void start(Stage stage) throws Exception { 
     SplitPane split = new SplitPane(); 
     StackPane child1 = new StackPane(); 
     child1.setStyle("-fx-background-color: #0000AA;"); 
     StackPane child2 = new StackPane(); 
     child2.setStyle("-fx-background-color: #00AA00;"); 
     StackPane child3 = new StackPane(); 
     child3.setStyle("-fx-background-color: #AA0000;"); 
     split.getItems().addAll(child1, child2, child3); 
     //split.setDividerPositions(0.1f, 0.6f, 0.9f) 
     stage.setScene(new Scene(split, 400, 300)); 
     stage.show(); 
    } 
    public static void main(String[] args) { 
     launch(args); 
    } 
} 
프로그램을 시작

enter image description here

내가 계속 그것도 작게 (창 너비가 정말 작게, 사진 없음) :

enter image description here

크기를 다시 조정하고 분배기가 프로그램 설정시 나 설정 방법이 아닌 것을 관찰하십시오. 이렇게

enter image description here

가까이 내가 기대했던 것과 그것을 만드는 :

칸막이가 잘못된 위치에 초기에는 더있는 것을 (나는를 SplitPane의 크기를 조정할 때까지, 1 x 1 픽셀은 충분하다) 창을 축소하는 경우를 제외하고
child1.setMinWidth(Region.USE_PREF_SIZE) 
    child1.setPrefWidth(100) 
    child2.setMinWidth(Region.USE_PREF_SIZE) 
    child2.setPrefWidth(200) 
    child3.setMinWidth(Region.USE_PREF_SIZE) 
    child3.setPrefWidth(300) 

너비, 구분선은 내부 구성 요소입니다.

어떻게하면 좋을까요?

답변

1

stage.widthProperty()stage.heightProperty()로 변경 리스너를 추가하려고합니다. 그리고이 전화 :

split.setDividerPositions(0.1f, 0.6f, 0.9f) 
관련 문제