环境:JDK1.8+IDEA
fxml载入项目
通过SceneBuilder编写好布局,生成fxml文件。
public void start(Stage stage) throws Exception {
stage.setTitle("calculator");
Pane load = FXMLLoader.load(getClass().getResource("cal.fxml"));
Scene scene =new Scene(load);
stage.setScene(scene);
stage.show();
}
fxml添加配置事件
创建一个eventcc类
public class eventcc {
@FXML
public void onevent(Event event){
EventType<? extends Event> eventType = event.getEventType();
System.out.println(eventType);
}
}
从fxml通过id引用控件
引用一定要加@FXML注解
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。