我需要一个标签窗格,左侧有标签,标签文字/图形需要水平
几个月前我在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)
有人可能会建议为什么这个标签不会像另一个那样旋转.
刚发布问题后你需要添加一个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)