【发布时间】:2014-04-16 13:02:00
【问题描述】:
我在 JavaFX 中创建了一个 Label,其中包含很多文本。
Label l1 = new Label("\t\tC-Mark and Attendance Calculator is a simple "
+ "software to find both the C-Mark and monthly attendance "
+ "of students. Inorder to use the features of this software,"
+ " user has to create an account for him first. Then he should "
+ "login using the username and password. He will be able to "
+ "perform all the operations then. Further details are mentioned"
+ " in the 'HELP' section in the user home page.");
l1.setWrapText(true);
l1.setTextAlignment(TextAlignment.JUSTIFY);
在此代码中,setWrapText(true) 不起作用。为什么?我怎样才能让它发挥作用?
【问题讨论】:
-
你是如何确定一个不起作用的?
-
@UlukBiy 因为我的标签内容是单行显示的。我不知道为什么会这样。你能提出一个解决方案吗?
-
设置标签的首选宽度。或者将标签放入调整其子级大小的窗格中,例如 HBox。
-
@UlukBiy 谢谢...首选宽度有帮助。
-
@TomJ,我也遇到了同样的问题,但没有通过设置首选宽度来解决。有什么想法吗?谢谢。