JavaFX: Task will not update UI


I'm working on an Omaha online poker client written in javaFX+java.

I need to show an anchorPane containing 3 buttons after finishes executing. I know for a fact that finishes executing but for some reason task.setOnSucceeded(new EventHandler() {'s handle method does not update the User interface.

What am I doing wrong?

public void newRound() {

    sog = StateOfGame.PREFLOP;       

     ControlGameOnNewThread control = new ControlGameOnNewThread();

    Task task = new Task() {

        protected Object call() throws Exception {
            return null;

    task.setOnSucceeded(new EventHandler() {

        public void handle(Event event) {
            if (client.getAction() == {
                System.out.println("Task finsished");
                    opponentBetField.setText(new Integer(opp.chipsInvested).toString());
                    myBetField.setText(new Integer(client.chipsInvested).toString());
                    System.out.println("Task finsished");


    new Thread(task).start();

4/22/2014 2:18:37 AM

As you override the call() method, you can override the succeeded() method: (See last example in the javadoc of Task.)

@Override protected void succeeded() {

succeeded() is already called on the JavaFX Application Thread, so you do not need to do this for yourself.

Are you sure, that the code in your handle method isn't called? Maybe a NullPointerException is thrown, which you might not see? Is the comparison working as expected?

Try moving the code with if (client.getAction()... into the overridden succeeded() method and put a println before the if-statement in order to see whether it is called or not.

(EDIT: typos)

4/23/2014 9:44:28 PM

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