I\'m new to javaFx,and I have found only within the @fxml function and initialize function the @fxml field not be null otherwise the @fxml field will always be null,is it true?
You are calling the static FXMLLoader.load(URL) method.
Since it's a static method, it knows nothing about the instance you are using to invoke it (which is bad practice anyway; your IDE should issue a warning about this). Specifically, it doesn't have a controller set.
You need to invoke an instance load() method, e.g.
FXMLLoader loader=new FXMLLoader();
loader.setController(this);
loader.setLocation(getClass().getResource("/fxml/Main.fxml"));
Parent pane = loader.load();
You can specify the controller in the FXML file. The FXMLLoader will initialize the variables in the controller. In that case there is not problem with your code. It is good practice to separate the controller from the main class.