Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Thread and button in JavaFX

 
Jack Tauson
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have the followign javafx code where It's showing a progressbar updating in 3 sec.



1) Basically, I want to add a Button in Icon as shown in Fig 3-2 here.

Using JavaFX UI Controls: Button | JavaFX 2 Tutorials and Documentation

I am wondering, where should I add the following code mentioned in the above link:



2) Then, I would like to kill the thread if a user want to using the button. Is it possible to kill a thread in JavaFX?How should I kill a thread? Please advise

Thanks
 
Martin Vajsar
Sheriff
Posts: 3752
62
Chrome Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1) There are many possibilities, but I'd say that adding the code to your start method would work fine in your case. However, the three lines just create the button, you need to insert it into the layout. I don't know Java FX, but I'd say it will be analogous to adding the progressbar (layout.getChildren().add(updProg);).

2) It's not possible to kill a thread in Java. You need to send some signal to the thread and have the thread check periodically for the signal and quit when it arrives. One possible way is to use the interrupt mechanism for this. It's explained in the Interrupt tutorial.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic