当前位置: 动力学知识库 > 问答 > 编程问答 >

java - Get Application class from event

问题描述:


I'm building app with JavaFX 2.x. Main method is in class Frame, which extends JavaFX Application. Controller binded from FXML template has event (button click), which is classof ActionEvent.


My question is, how is all of that linked? I wanna get applicaiton instance (Frame) from event.


I've some dirty and ugly solution (static function to set/get app instance).... is there cleaner way?



Thanks

P.S. I know, how to get scene, stage (window?), but don know, "where" is instance of application (place, where is main());

P.P.S I'm n00bee in JavaFX technology

网友答案:

Use a static getter returning the Application instance from your Application subclass (as you have currently implemented it).

I think other potential solutions will end up clunkier.

分享给朋友:
您可能感兴趣的文章:
随机阅读: