How to set button text in JavaFX?

后端 未结 2 1680
旧时难觅i
旧时难觅i 2021-01-29 07:15

I\'m trying to set the button text using this code:

public void initialize(URL location, ResourceBundle resources) {
    // TODO Auto-generated method stub
    /         


        
2条回答
  •  有刺的猬
    2021-01-29 07:52

    Are you sure your elements are actually not null and that your assert statements are actually doing what they're supposed to? Click me for info on using assert statements. Make sure your variable declarations are left as @FXML private Button fx_btnHourUp; and that you never instantiate the button yourself via fx_btnHourUp = new Button();.

    Are you using SceneBuilder 2.0 to create your fxmls? It's a program that allows you to design fxmls while avoiding many of these kinds of common errors. Download link here.

提交回复
热议问题