Launch javaFX app from java code


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

   initJavaFXapp();  // I am struggling to do this

//keep reading from server 
if(obj instanceOf gameState)

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.

2/20/2013 2:02:42 AM

Accepted Answer

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

2/20/2013 4:06:08 AM

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