JavaFx:将文本设置为来自两个不同函数的标签时出现NullPointerException

时间:2015-10-19 01:03:56

标签: java javafx fxml

当用户选择给定的Tab时,我正在更改fxml文件中的Label。我将每个选项卡设置为#OnSelectionChanged的给定函数,并且还为该特定Label设置了一个变量。我不明白为什么Label被正确更改了,但是我收到错误

引起:java.lang.NullPointerException     在elorankings.controller.PRSettingsController.changeToIndivLabel(PRSettingsController.java:137)

以下是我所做的一些工作。

@FXML
private Label addPlayersInfo;
@FXML
private Tab addBulkTag;
@FXML
private Tab addIndivTag;



@FXML
private void changeToBulkLabel(){
    addPlayersInfo.setText("Add 1 player per line and to add player ranking, seperate them with comma"
            + "\n\nExample:"
            + "\nPlayers Tag, 1600"
            + "\n\nOR"
            + "\n\nPlayers Tag");

}

@FXML
private void changeToIndivLabel(){
    addPlayersInfo.setText("Add Players Individually by providing a tag name and initial ranking.  If no Initial ranking is provided, then player will have the initial ranking that was set on the previous page.");
}

Tab ID and #OnSelectionChanged

Other Tab ID and #OnSelectionChanged

addPlayersInfo标签在FXML文件中设置如下

<Label fx:id="addPlayersInfo" alignment="TOP_CENTER" layoutX="511.0" layoutY="29.0" maxHeight="-Infinity" maxWidth="-Infinity" prefHeight="375.0" prefWidth="180.0" text="Add Players Individually by providing a tag name and initial ranking.  If no Initial ranking is provided, then player will have the initial ranking that was set on the previous page." wrapText="true">

<font>

   <Font size="16.0" />

</font>

提前感谢所有帮助!

0 个答案:

没有答案