Javafx旋转标签问题

Kha*_*ela 6 javafx-2

  • 当我尝试将标签旋转270时,我遇到了问题label.setRotate(270).
  • 但标签文字消失了.

标签文字消失了

  • 这是代码示例.

    LineChart chart = new LineChart(new CategoryAxis(), new NumberAxis());
    chart.setLegendVisible(false); 
    
    /**
     * Grid pane which contain the charts and vertical label to indicate for the row title
     */
    GridPane root = new GridPane();
    root.add(chart, 0, 0);
    
    /**
     * Want to add vertical label to refer to the row title.
     */
    Label label = new Label("Row Title");
    label.setRotate(270);
    // label.setMinWidth(200); 
    
    root.add(label, 1, 0);
    
    Run Code Online (Sandbox Code Playgroud)

更新

  • 当我尝试setMinWidth(200)出现另一个问题时. 旋转后,标签仍然占据宽度空间

Ulu*_*Biy 0

您看到的文本是文本因边界狭窄而被截断时...的默认值。失踪问题应该得到解决ellipsisStringPropertylabel.setMinWidth(200);