如何减少垂直文本/标签

Mag*_*ine 0 text javafx rotation width

我想在HBox的左侧放置一个垂直(90度旋转)标签.网格窗格应填写整个剩余空间.如果我减少旋转标签的含量以减少其所需的水平空间,则文本长度会缩小.否则,如果我手动降低高度,则没有任何反应.

如何减少旋转标签的使用?

使用Scenebuilder和Windows 7.

Jam*_*s_D 5

旋转Label并将其包裹在一个Group.在将转换应用于标签后,将计算组的布局边界:

import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.layout.HBox;
import javafx.stage.Stage;

public class RotatedLabelTest extends Application {

    @Override
    public void start(Stage primaryStage) {
        Label hello = new Label("Hello");
        Label world = new Label("World");
        hello.setRotate(90);
        world.setRotate(90);
        HBox root = new HBox(5, new Group(hello), new Group(world));

        primaryStage.setScene(new Scene(root));
        primaryStage.show();
    }

    public static void main(String[] args) {
        launch(args);
    }
}
Run Code Online (Sandbox Code Playgroud)