JavaFX FXML Controller initialize method not invoked

前端 未结 3 1015
梦毁少年i
梦毁少年i 2021-01-18 04:33

I am trying to fill ListView from the content of a simple ArrayList. Here is my

Controller.java file:

package design;
import java.net.URL;
import jav         


        
3条回答
  •  庸人自扰
    2021-01-18 05:05

    If I see correctly, you actually don't use the URL and the ResourceBundle parameters in you initialize() method. If the URL is the path to your fxml file, and the ResourceBundle contains internatonalization properties for your GUI, then you should define your initialize() method without parameters, but annotated with @FXML. The URL and the ResourceBundle should be passed to the FXMLLoader.

    Like

    FXMLLoader loader = new FXMLLoader(URL, rb);
    

    and

    @FXML
    private void initialize() { ... }
    

    This way initialize() will be automatically invoked.

提交回复
热议问题