Launch javaFX app from java code


Question

I have a JavaFX card game currently running for single player. I want to enable multiple players playing over TCP socket connections, for which I have a simple client/server skeleton program written in java.

My problem is: the server/client code is in java. How do I launch the javafx app from the client java code, and then update it based on the gamestate returned from the server?

Simple server-client loop will be: client sends action, server updates gamestate, and echoes it back out to 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 beginner to using javaFX, and I utilised the graphics aspect as my app is based on it.

Any help would be much appreciated.

1
5
2/20/2013 2:02:42 AM

Accepted Answer

Assuming MyApplication class extends javafx.application.Application you can launch it next way:

 javafx.application.Application.launch(MyApplication.class);
16
2/20/2013 4:06:08 AM

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon