0

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.

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...

brunob
  • 39
  • 3
  • 8
  • 1
    `MainGUI` is a regular java class that extends `javafx.application.Application`. You can use the Main.java and its methods in it. What do you mean by "connect" more specifically? – Uluk Biy Aug 16 '12 at 11:01
  • 1
    Are the JavaFX GUI and the Backend executed on the same machine? – Cephalopod Aug 16 '12 at 11:05
  • Would you know how to do it in Swing or AWT? If you do, you can think along the same lines and exchange the names. (You'll miss out on some points, though, but you can remedy that once you learn.) – Urs Reupke Aug 16 '12 at 11:08
  • @UlukBiy: So should I just instantiate the Main.java class in the start method of MainGUI.java and that's it? – brunob Aug 16 '12 at 11:29
  • @Arian: Yes, they are executed on the same machine. – brunob Aug 16 '12 at 11:30
  • @UrsReupke: Not in Swing or AWT, just Java and JavaFX. – brunob Aug 16 '12 at 11:30

3 Answers3

0

Since it is a GUI library, not an application framework, there is no model/view concept in JavaFX.

You'll have to connect your classes manually.

Urs Reupke
  • 6,791
  • 3
  • 35
  • 49
0

MainGUI is a regular java class that extends javafx.application.Application. You can instantiate the Main class and use its methods in it.

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.

Community
  • 1
  • 1
Uluk Biy
  • 48,655
  • 13
  • 146
  • 153
0

Two ways: 1) Front end will spawn a thread to backend 2) You can manually create a method object which can access