Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java FX8 Tabs on the left side with horizontal tabs

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.

like image 868
abacusreader Avatar asked Jun 14 '14 11:06

abacusreader


1 Answers

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

like image 197
abacusreader Avatar answered Oct 03 '22 12:10

abacusreader