Java FX8选项卡左侧带有水平选项卡

aba*_*der 5 javafx javafx-8

我需要一个标签窗格,左侧有标签,标签文字/图形需要水平

几个月前我在Scenebuilder上做过这个.

但是,当我通过Java代码添加其他选项卡时,选项卡位于左侧,但图形文本是垂直的,与使用"场景"构建器创建的选项卡不同.

在附图中,前两个选项卡通过Scenebuilder创建,它们的方向正确,第三个是使用Java代码动态添加的.

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);
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

有人可能会建议为什么这个标签不会像另一个那样旋转.

aba*_*der 5

刚发布问题后你需要添加一个StackPane,其中包含一个包含标签的组来实现这个目的.

  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);
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

  • 您需要在添加任何选项卡之前添加 tabpane.setRotateGraphic(true) ,这在我的代码中不清楚,因为它是在 FXML 端完成的。 (2认同)