如何防止文本在JavaFX中的小按钮上转向省略号? [英] How to prevent text from turning to ellipsis on small buttons in JavaFX?
问题描述
如果我使按钮相对较小,则其标题将变为省略号。
If I make button relatively small, it's caption turns to ellipsis.
如何关闭此功能?
推荐答案
不要让按钮低于它的首选尺寸,那么它永远不需要忽略按钮标签的文字:
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:
- 应用CSS以在按钮中使用非常小的字体。
- 使按钮的标签文本非常短。
- 使用 brian的答案建议明确将椭圆字符串设置为空。
- 使用小图形图标代替文本。
- Apply CSS to use a very small font in the button.
- Make the label text for the button very short.
- Use brian's answer which proposes explicitly setting the ellipse string to empty.
- Use a small graphic icon instead of text.
如上所述,您可以在所有情况下使用 setMinSize
(如果你希望按钮不要低于首选大小截断或删除内容。)
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).
在所有情况下,如果你愿意,你也可以应用CSS来最小化之间的填充标签和按钮边框。
In all cases, if you wish, you can also apply CSS to minimize the padding between the label and button the border.
从您之前的评论(我想使用简单的标题,如<和>),我认为选项2(制作标签文字对于按钮非常短)是你想要的。
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.
你可能也对Joel的为那些对生活做得更好的人设计,这表明可用性方面非常小的按钮通常是一个非常糟糕的主意。
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屋!