JavaFX FXML控制器-构造函数VS初始化方法
Application
public class Test extends Application { private static Logger logger = LogManager.getRootLogger(); @Override public void start(Stage primaryStage) throws Exception { String resourcePath = "/resources/fxml/MainView.fxml"; URL location = getClass().getResource(resourcePath); FXMLLoader fxmlLoader = new FXMLLoader(location); Scene scene = new Scene(fxmlLoader.load(), 500, 500); primaryStage.setScene(scene); primaryStage.show(); } public static void main(String[] args) { launch(args); }}
FXMLLoader
FXML
fx:controller
initialize
public class MainViewController { public MainViewController() { System.out.println("first"); } @FXML public void initialize() { System.out.println("second"); }}
first second
initialize
initialize
慕尼黑5688855
莫回无
相关分类