I have a Java-code business logic and a JavaFX2-code GUI. A Java Game.java
class interacts with a GameGUI.java
FX class via an EventBroker and listeners. The main classes are in the back-end package Main.java
and in the front-end package MainGUI.java
, so the application is started from the start-method in the MainGUI
class.
我有一个Java代码业务逻辑和一个JavaFX2代码GUI。 Java Game.java类通过EventBroker和侦听器与GameGUI.java FX类进行交互。主要类位于后端程序包Main.java和前端程序包MainGUI.java中,因此应用程序从MainGUI类的start-method启动。
How can I connect the back-end (Main) with the front-end (MainGUI)? Is there a method to set the Java back-end classes as model for the GUI? I'm just getting started with JavaFX...
如何将后端(Main)与前端(MainGUI)连接?有没有一种方法可以将Java后端类设置为GUI的模型?我刚刚开始使用JavaFX ......
3 个解决方案
#1
0
MainGUI
is a regular java class that extends javafx.application.Application
. You can instantiate the Main
class and use its methods in it.
MainGUI是一个扩展javafx.application.Application的常规java类。您可以实例化Main类并在其中使用其方法。
Furthermore, to understand the MVC-like pattern of JavaFX refer to these links:
Mastering FXML part "Introduction to FXML".
MVC Pattern in JavaFX With Scene Builder.
此外,要了解类似MVC的JavaFX模式,请参考以下链接:掌握FXML部分“FXML简介”。使用Scene Builder在JavaFX中创建MVC模式。
#2
0
Since it is a GUI library, not an application framework, there is no model/view concept in JavaFX.
由于它是一个GUI库,而不是一个应用程序框架,因此JavaFX中没有模型/视图概念。
You'll have to connect your classes manually.
您必须手动连接您的类。
#3
0
Two ways: 1) Front end will spawn a thread to backend 2) You can manually create a method object which can access
两种方式:1)前端将产生一个线程到后端2)你可以手动创建一个可以访问的方法对象
#1
0
MainGUI
is a regular java class that extends javafx.application.Application
. You can instantiate the Main
class and use its methods in it.
MainGUI是一个扩展javafx.application.Application的常规java类。您可以实例化Main类并在其中使用其方法。
Furthermore, to understand the MVC-like pattern of JavaFX refer to these links:
Mastering FXML part "Introduction to FXML".
MVC Pattern in JavaFX With Scene Builder.
此外,要了解类似MVC的JavaFX模式,请参考以下链接:掌握FXML部分“FXML简介”。使用Scene Builder在JavaFX中创建MVC模式。
#2
0
Since it is a GUI library, not an application framework, there is no model/view concept in JavaFX.
由于它是一个GUI库,而不是一个应用程序框架,因此JavaFX中没有模型/视图概念。
You'll have to connect your classes manually.
您必须手动连接您的类。
#3
0
Two ways: 1) Front end will spawn a thread to backend 2) You can manually create a method object which can access
两种方式:1)前端将产生一个线程到后端2)你可以手动创建一个可以访问的方法对象