• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Liutauras Vilda
Sheriffs:
  • Paul Clapham
  • Jeanne Boyarsky
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
Bartenders:
  • Jesse Duncan
  • Frits Walraven
  • Mikalai Zaikin

Thread and button in JavaFX

 
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 3837
66
Netbeans IDE Oracle Firefox Browser
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
pie. tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic