Results 1 to 2 of 2
  1. #1
    Jack_Tauson_Sr is offline Senior Member
    Join Date
    Nov 2011
    Rep Power

    Default Dealign with thread and button

    I have the followign javafx code where It's showing a progressbar updating in 3 sec.
    Java FX Code:
     * To change this license header, choose License Headers in Project Properties.
     * To change this template file, choose Tools | Templates
     * and open the template in the editor.
    package javafxapplication1;
    import javafx.application.Application;
    import javafx.concurrent.Task;
    import javafx.event.ActionEvent;
    import javafx.event.EventHandler;
    import javafx.scene.Scene;
    import javafx.scene.control.Button;
    import javafx.scene.control.ProgressBar;
    import javafx.scene.layout.StackPane;
    import javafx.stage.Stage;
     * @author me
    public class JavaFXApplication1 extends Application {
       public static void main(String[] args) { Application.launch(args); }
      @Override public void start(Stage stage) {
        Task<Void> task = new Task<Void>() {
          @Override public Void call() {
            for (int i = 1; i < 10; i++) {
              try {
              } catch (InterruptedException e) {
              updateProgress(i, 10);
            return null;
        ProgressBar updProg = new ProgressBar();
        Thread th = new Thread(task);
        StackPane layout = new StackPane();
        layout.setStyle("-fx-background-color: cornsilk; -fx-padding: 10;");
        stage.setScene(new Scene(layout));;

    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:

    Java FX Code:
    Image imageDecline = new Image(getClass().getResourceAsStream("not.png"));
    Button button5 = new Button();
    button5.setGraphic(new ImageView(imageDecline));
    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


  2. #2
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Eastern Florida
    Rep Power

    Default Re: Dealign with thread and button

    If you don't understand my response, don't ignore it, ask a question.

Similar Threads

  1. Replies: 3
    Last Post: 10-23-2013, 07:38 AM
  2. Replies: 7
    Last Post: 08-06-2011, 03:39 AM
  3. Make a button class that uses your button image.
    By eLancaster in forum New To Java
    Replies: 1
    Last Post: 04-26-2011, 11:32 AM
  4. Adding a sqrt button and percentage button to a calculator
    By Josie_Taylor in forum New To Java
    Replies: 4
    Last Post: 03-14-2011, 02:16 AM
  5. Stopping a thread using a stop button - GUI
    By Ben1 in forum New To Java
    Replies: 5
    Last Post: 01-27-2011, 05:21 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts