Rotating label 90 degrees takes up unnecessary horizontal space

烂漫一生 提交于 2019-12-14 03:45:38

问题


This question is based on Javafx rotate Label issue, but because this post is outdated and has no satisfying answer, I would like to mention it again.

The problem is:

When rotating a label for 90 or 270 degrees, firstly the text is being truncated because it has not the right minimum width. When I set the minimum width, the text is not being truncated anymore.

However, the minimum width is also set in the horizontal direction, as shown below:

On the left is the situation as it is now in Java 8u40, and on the right is how I like it to be (and which is the most logical way in my opinion).

I have just used this code:

Label label = new Label("This is a label.");
label.setRotate(270);
label.setMinWidth(200);

I have added the label to a AnchorPane, which is not part of the problem I except. I also tried @James_D workaround (https://community.oracle.com/thread/3514254), which did not work for me either.

So my question is:

Is this a known bug, and if so: is there any chance it will be fixed in the future? Also, is there another workaround possible (apart from placing the label in an image)?


回答1:


In my opinion it´s a bug. I did a test with a JavaFX app with rotating text on Windows (running Oracle JavaFX, JDK1.8.0.60j and then I moved it to Raspberry Pi. The Pi was running Open JavaFX. In Open JavaFX the rotation is performed correctly, while the Oracle JavaFX shows the behaviour you decribed here.



来源:https://stackoverflow.com/questions/29031565/rotating-label-90-degrees-takes-up-unnecessary-horizontal-space

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!