2017-01-27 2 views
0

나는 플로우 팬을 사용하여 탭 패널로 전환 중입니다. 나는 어떻게해야할지 모른다. 캔버스와 창을 탭 페인 내에 사용하고 싶습니다. 가능합니까? 다음은JavaFX에서 TabPane 사용

public View(TabPane root) { 
    this.root = root; 

    tab1 = new Tab(); 
    root.getTabs().add(tab1); 

    tab2 = new Tab(); 
    root.getTabs().add(tab2); 

    ui = new Pane(); 

    canvas = new Canvas(600,600); 
    //gc is graphics context 
    gc = canvas.getGraphicsContext2D(); 

    //this is where the problem is?? 
    //i have no idea how to add ui and canvas to my tab1 
    tab1.getChildren().addAll(ui, canvas); 
} 

답변

0

TabPane의 서브 클래스가 아닌 모든 스타일링없이 내 코드 등이다, 그래서 더 getChildren() 방법이 없습니다.

대신 content property 값을 탭에 표시된 노드로 사용합니다 (탭에 노드가 하나만 있음).

그래서 당신은

tab1.setContent(canvas); 

으로 탭에서 캔버스를 표시 할 수 있으며, 표시 할 두 가지가 있다면 물론, 당신은 컨테이너에 탭의 내용을 다른 용기에 넣어 및 설정합니다 :

VBox vbox = new VBox(ui, canvas); 
tab1.setContent(vbox); 
관련 문제