Why doesn't my form loads when adding code to initialize?

Or tell me how to refactor your code. How to do it right. The point is that the server will receive a string and need minimal graphical support type "works\does not work"
PS it seemed to me logical to wrap the call server Platform.runlatter, but in this situation the application tightly to lie on the barrels and does not want to answer
public class AppDesktop extends Application implements Initializable {

 public static void main(String[] args) {
launch(args);
}
@Override
 public void start(Stage primaryStage) throws Exception {
 Parent root = FXMLLoader.load(getClass().getClassLoader().getResource("MainWin.fxml"));

 primaryStage.setTitle("Log share :)");
 primaryStage.setScene(new Scene(root, 900, 500));
primaryStage.show();



}

@Override
 public void initialize(URL location, ResourceBundle resources) {



 try {
 new Server();
 } catch (IOException e) {
e.printStackTrace();
}

}
}

Server
public class Server implements ConnectionListener{


 public static void main(String[] args) {

 try {
 new Server();
 } catch (IOException e) {
e.printStackTrace();
}

}

 private static final int PORT = 2454;
 List<Connection> connectionList = new ArrayList();


 public Server() throws IOException {


 ServerSocket serverSocket = new ServerSocket(PORT);

 while (true) {
 new Connection(this, serverSocket.accept());
}
}






@Override
 public synchronized void onConnectionReady(Connection connection) {

 System.out.println("new client Connected" + connection.toString());
connectionList.add(connection);

}

@Override
 public synchronized void newMessageOn(Connection connection, String message) {

System.out.println(message);
sendToAll(message);
openWebpage(message);



}

 public static boolean openWebpage(String link) {
 URI u = null;
 try {
 u = new URI(link);
 } catch (URISyntaxException e) {
e.printStackTrace();
}
 Desktop Desktop = Desktop.isDesktopSupported() ? Desktop.getDesktop() : null;
 if (desktop != null && desktop.isSupported(Desktop.Action.BROWSE)) {
 try {
desktop.browse(u);
 return true;
 } catch (Exception e) {
e.printStackTrace();
}
}
 return false;
}


@Override
 public synchronized void connectionException(Connection connection, Exception exception) {

}

@Override
 public synchronized void onDisconnect(Connection connection) {

connectionList.remove(connection);
 System.out.println("Client disconnected:" + connection);
}


 private void sendToAll(String message) {
 connectionList.forEach((connection) -> connection.sendString(message));
}


}


Connection
public class Connection {


 private final Socket socket;
 private final ConnectionListener eventListener;
 private final BufferedReader in;
 private final BufferedWriter out;
 private Thread connectionThread;


/**
 * The constructor for your customers
 * @param connectionListener
 * @param port the port to connect
 * @param ip_adress ip address to connect
*/
 public Connection(ConnectionListener connectionListener, String ip_adress, int port) throws IOException {

 this(connectionListener, new Socket(ip_adress, port));

}

/**
 * Designer backend
 * @param listener
 * @param socket
*/
 public Connection(ConnectionListener listener, Socket socket) throws IOException {

 this.socket = socket;
 eventListener = listener;

 in = new BufferedReader(new an InputStreamReader(socket.getInputStream(), Charset.forName("UTF-8")));
 out = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream(), Charset.forName("UTF-8")));


 connectionThread = new Thread(() -> {

 try {

eventListener.onConnectionReady(Connection.this);

 while (!connectionThread.isInterrupted()) {

 eventListener.newMessageOn(Connection.this, in.readLine());

}
 } catch (IOException e) {
 eventListener.connectionException(Connection.this, e);
 } catch (Exception e) {
e.printStackTrace();
 } finally {
eventListener.onDisconnect(Connection.this);
}
});

connectionThread.start();
}


 public synchronized void sendString(String value) {

 try {

 out.write(value + "\r\n");

out.flush();

 } catch (IOException e) {

 eventListener.connectionException(this, e);

disconnect();

}

}

 public synchronized void disconnect() {

connectionThread.interrupt();

 try {
socket.close();
 } catch (IOException e) {
 eventListener.connectionException(this, e);
}

}


@Override
 public String toString() {
 return "Connection:" + socket.getInetAddress() + ": "+ socket.getPort();
}

}
March 19th 20 at 08:34
1 answer
March 19th 20 at 08:36
While he explained about platforms relater yourself understood - is a fairly lightweight task to use rolater and wrapped everything in Service :) it Turns out that when you write about a problem it seems better!

So works perfectly:
Service<Void> service = new Service<Void>() {
@Override
 protected Task<Void> createTask() {
 return new Task<Void>() {
@Override
 protected Void call() throws Exception {


 try {
 new Server();
 } catch (IOException e) {
e.printStackTrace();
}
 return null;
}
};
}
};
 service.start();

Find more questions by tags JavaFXJava