Java FX8 Tabs on the left side with horizontal tabs


Question

I require a tabbed pane with tabs on the left side, the tab text/graphic needs to be horizontal

I did this on Scenebuilder few months back.

However when I add additional tabs via Java code, the tabs is on the left side but the graphic text is vertical unlike the tabs created using Scene builder.

In the attached image first two tabs are created through Scenebuilder and they are in the correct orientation, the third one was dynamically added using Java code.

Tab studentAdmission = new Tab();
        studentAdmission.setContent((Parent)new FXMLLoader(getClass().getResource("Customer_View.fxml")).load());


        studentAdmission.setGraphic(new Label("Student Admission"));
        mainTab.getTabs().add(studentAdmission);

enter image description here

Could some one advise why this tab doesn't rotate as the other one.

1
5
6/14/2014 11:17:48 AM

Accepted Answer

Just figured out after posting the question that you need to add a StackPane containing a group containing a label to achieve this.

  Tab studentAdmission = new Tab();
     studentAdmission.setContent((Parent)new FXMLLoader(getClass().getResource("Customer_View.fxml")).load());

    Label l = new Label("Student Admission");
    l.setRotate(90);
    StackPane stp = new StackPane(new Group(l));
    studentAdmission.setGraphic(stp);
    mainTab.getTabs().add(studentAdmission);

enter image description here

5
6/14/2014 11:22:45 AM

    // Firstly
    tabPane.setSide(Side.LEFT);
    tabPane.setRotateGraphic(true);        

    Label l = new Label("Titel Tab1");
    l.setRotate(90);
    StackPane stp = new StackPane(new Group(l));
    stp.setRotate(90);
    tab1.setGraphic(stp);

    l = new Label("Titel Tab2");
    l.setRotate(90);
    stp = new StackPane(new Group(l));
    stp.setRotate(90);
    tab2.setGraphic(stp);

    tabPane.setTabMinHeight(100);
    tabPane.setTabMaxHeight(100);

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon