如何防止文本在 JavaFX 中的小按钮上变成省略号? [英] How to prevent text from turning to ellipsis on small buttons in JavaFX?

查看:16
本文介绍了如何防止文本在 JavaFX 中的小按钮上变成省略号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我让按钮相对较小,它的标题会变成省略号.

如何关闭此功能?

解决方案

不要让按钮低于它的首选大小,这样它就永远不需要删除按钮标签的文本:

button.setMinSize(Button.USE_PREF_SIZE, Button.USE_PREF_SIZE);

<块引用>

我想做一个很小的按钮

您可以单独或组合使用以下任何一项:

  1. 应用 CSS 以在按钮中使用非常小的字体.
  2. 使按钮的标签文本非常短.
  3. 使用 brian 的答案,建议将椭圆字符串显式设置为空.
  4. 使用小图形图标代替文本.

您可以在所有情况下使用上面记录的 setMinSize(如果您希望按钮不低于截断或删除内容的首选大小).

在所有情况下,如果您愿意,您还可以应用 CSS 来最小化标签和按钮边框之间的填充.

根据您之前的评论(我想使用诸如<"和>"之类的简单标题),我认为选项 2(使按钮的标签文本非常短)就是您想要的.

您可能还对 Joel 的 为有更好事情要做的人而设计感兴趣生活这表明,在可用性方面,非常小的按钮通常是一个非常糟糕的主意.

If I make button relatively small, it's caption turns to ellipsis.

How to turn off this feature?

解决方案

Don't let the button go below it's preferred size, then it will never need to elide the text of the button label:

button.setMinSize(Button.USE_PREF_SIZE, Button.USE_PREF_SIZE);

I want to make very small button

You can use any of the below either separately or in combination:

  1. Apply CSS to use a very small font in the button.
  2. Make the label text for the button very short.
  3. Use brian's answer which proposes explicitly setting the ellipse string to empty.
  4. Use a small graphic icon instead of text.

You can use setMinSize as documented above in all cases (if you wish the button not to go below a preferred size truncating or eliding content).

In all cases, if you wish, you can also apply CSS to minimize the padding between the label and button the border.

From your previous comment (I want to use simple captions like "<" and ">"), I think option 2 (Make the label text for the button very short) is what you want.

You may also be interested in Joel's Designing for People Who Have Better Things To Do With Their Lives which would indicate, usability-wise that very small buttons are usually a pretty bad idea.

这篇关于如何防止文本在 JavaFX 中的小按钮上变成省略号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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