[英]Eclipse e4 with JavaFX - How to get instances of Application and Stage (javafx)?
我正在嘗試將GraniteDS框架添加到Javafx E4應用程序。 我已經將GraniteDS Javafx庫綁定到包中,可以在JavaFX OSGi應用程序中對其進行初始化(osgi應用程序具有帶有我需要的參數的jfxStart方法)。
但是在Javafx E4應用程序(使用e(fx)clipse向導創建)中,沒有帶有啟動功能的類。 在osgi應用中,代碼為:
protected void jfxStart(IApplicationContext applicationContext, Application jfxApplication, Stage primaryStage) {
contextManager = new SimpleContextManager(new JavaFXApplication(jfxApplication, primaryStage));
contextManager.initModules(App.class);
Context context = contextManager.getContext();
context.set(this);
.......
}
問題是-如何在Javafx E4應用程序中獲取jfxApplication
和primaryStage
實例,以及在何處執行初始化(可能在Activator start方法中)?
兩者都可以通過DI獲得:
class MyComponent {
@Inject
public MyComponent(Application app, @Named("primaryStage") Stage primaryStage) {
}
}
請注意,e4 + JavaFX應用程序中從未顯示primaryStage,因此您可能真的希望擁有所顯示的舞台-因此,最有可能的是
class MyComponent {
@Inject
public MyComponent(Application app, Stage primaryStage) {
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.