如何在JavaFX中很好地对齐标签的内容

时间:2014-03-28 06:17:09

标签: javafx javafx-2 label textwrapping

以下代码是我的JavaFX应用程序中标签的代码。它有一些问题。 setWrapText()和setTextAlignment()方法正在运行,但也存在一些缺陷。主要缺点是,某些词之间没有空格。由于没有空格,因此它们只显示为一个单词。

我该如何解决这个问题?

    Label t1;
    t1 = new Label("\t\t Here you add the details of the staff, subject and students. "
            + "Then allocate staff for each subject. They will perform mark "
            + "entry for each and every student, you entered. You just check "
            + "whether they are doing everything as per your advice. "
            + "You can view the marklist of every subject since you "
            + "are the tutor of the class.");
    t1.setWrapText(true);
    t1.setTextAlignment(TextAlignment.JUSTIFY);
    t1.setPrefWidth(560);
    t1.setFont(Font.font("Calibri", FontWeight.BOLD, 16));
    t1.setTextFill(Color.BLACK);

1 个答案:

答案 0 :(得分:0)

对我来说很好。

image

OS X 10.9,Java 8b129,Macbook Air 2012。