Run javaFX application from Java code

I have a JavaFX card game currently working for a single player. I want to include some players playing through TCP socket connections, for which I have a simple skeleton client / server program written in java.

My problem: server / client code is in java. How to run a javafx application from client java code and then update it based on gamestate returned from the server?

A simple client-client cycle would be: the client sends an action, updates the server, and then sends it back to the client.

client pseudo-code

if(!clientGUI.isInitialised())
   initJavaFXapp();  // I am struggling to do this

//keep reading from server 
if(obj instanceOf gameState)
    javaFXGUI.update(obj)

I am starting to use javaFX and I used the graphic aspect as my application is based on it.

Any help would be greatly appreciated.

+5
source share
1

, MyApplication class extends javafx.application.Application :

 javafx.application.Application.launch(MyApplication.class);
+16

All Articles