Reputation: 41
I am writing a JavaFX program under ecilpse, It works well on my local machine i.e., I can execute the runable jar after I export. However, when I put the executable jar to another machine, the UI was not responding. Here are the codes I launch the javaFX program.
@Override
public void start(Stage primaryStage) {
primaryStage.setOnCloseRequest(new EventHandler<WindowEvent>() {
@Override
public void handle(WindowEvent e) {
Platform.exit();
System.exit(0);
}
});
this.primaryStage = primaryStage;
this.primaryStage.setTitle("Server Simulator");
context = new ClassPathXmlApplicationContext("classpath:PrTrSim.xml");
this.displayQueue = (LinkedBlockingQueue<Message>) context.getBean("displayQueue");
this.userInputQueue = (LinkedBlockingQueue<Message>) context.getBean("userInputQueue");
this.outgoingQueue = (LinkedBlockingQueue<Message>) context.getBean("outgoingQueue");
this.incomingQueue = (LinkedBlockingQueue<Message>) context.getBean("incomingQueue");
addQueue.add(this.displayQueue);
addQueue.add(this.outgoingQueue);
addQueue.add(this.incomingQueue);
initRootLayout();
showSimOverview();
}
public static void main(String[] args) {
launch(args);
}
The PrTrSim.xml is for initialization of two components(messageProcessor and SocketIO reader) which are running behind.The 4 blocking queues are for message receiving and handling.
Upvotes: 0
Views: 679
Reputation: 185
To avoid blocking of the main thread you should use the JavaFX concept of tasks or services as explained in details here: http://docs.oracle.com/javafx/2/threads/jfxpub-threads.htm
Upvotes: 1