用javaFX开发桌面应用遇到以下问题,
fxml里定义界面
在java程序里获取fxml定义的界面并显示
问题:我想获取fxml里定义的button控件和webview控件,查了很多资料还是没明白该怎么做?
难道JavaScript的getElementById和Android的findViewById在JavaFX里面没有嘛?
谢谢
Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
在fxml中设置fx:controller,然后控件设置fx:id,然后在Controller中使用@FXML注解相应的控件对象。
类似js和Android中的方法可以使用:
Button button = (Button)parent.lookup("#myButton");