简体   繁体   中英

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

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.

假设MyApplication类扩展了javafx.application.Application您可以在下一步启动它:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM