将标签旋转90度会占用不必要的水平空间 [英] Rotating label 90 degrees takes up unnecessary horizontal space

查看:86
本文介绍了将标签旋转90度会占用不必要的水平空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此问题基于 Javafx旋转标签问题,但由于此帖子已过时且没有令人满意的答案,我想再次提及.

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.

问题是:

将标签旋转90或270度时,首先,由于文本没有正确的最小宽度,因此文本被截断了.当我设置最小宽度时,文本不再被截断.

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:

左边是Java 8u40的情况,右边是我喜欢的样子(这是我认为最合乎逻辑的方式).

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);

我已将标签添加到AnchorPane,这不是我的问题的一部分.我还尝试了@James_D解决方法( https://community.oracle.com/thread/3514254 ),这对我也不起作用.

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.

所以我的问题是:

这是一个已知的错误吗?如果是这样:将来是否有可能修复该错误?另外,是否有其他解决方法(除了将标签放置在图像中)?

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)?

推荐答案

在我看来,这是一个错误.我使用JavaFX应用程序进行了测试,该应用程序在Windows上旋转文本(运行Oracle JavaFX,JDK1.8.0.60j,然后将其移至RaspberryPi.Pi运行的是Open JavaFX.在Open JavaFX中,旋转正确执行,而Oracle JavaFX会显示您在此处描述的行为.

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.

这篇关于将标签旋转90度会占用不必要的水平空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆