Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

remove children HBox (Multithread)

user11175597Oct 30 2013 — edited Oct 31 2013

Hello,

I'm trying to use the Task and Service classes to do multithreading treatment on my javafx application. But im quite confused about it.

Here are the steps i want to follow :

   1) I click on one of my IHM button.

   2) the click handler launch a parallel thread (Task) which execute complex and long treatment. In the meantime the javafx thread is terminating and the gui is released.

   3) When the calculation are finished on the parallel thread, it change the children on one of my ihm hbox.

Here the code i made.

click_handler :

[CODE]

HBox hboxResultat = (HBox) vboxListInput .getChildren().get(indexHbox);

Task<HBox> taskProcessWord = new Task<HBox>() {

    @Override protected HBox call() throws Exception {

       try {

            //Long and complex calculation.

       } catch (Exception e) {

            log.error(e);

       }

       //reinit hbox

       HBox myHbox = new HBox();

        //add nodes to hbox

        addInfosToHbox(myHbox);

        return myHbox;

    }

};

hboxResultat = taskProcessWord.valueProperty().get();

Thread th = new Thread(taskProcessWord);

th.setDaemon(true);

System.out.println("Starting background task...");

th.start();

[/CODE]

the code above doesn't produce any result. Can u help me?

This post has been answered by James_D on Oct 30 2013
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 28 2013
Added on Oct 30 2013
2 comments
606 views