Locking the GUI, spinning dial (simillar to JXLayer)

Hello,
I am looking for a way to lock the GUI (and display a spinning dial) when a long running thread is running.
How would one do this with JavaFX?
Thanks in advance

Yes. Using a progress indicator instead of a cursor is a good idea.
   import javafx.application.Application;
import javafx.beans.binding.When;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.concurrent.Task;
import javafx.concurrent.Worker.State;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
import javafx.scene.Cursor;
import javafx.scene.control.ProgressIndicator;
public class TaskProgs extends Application {
    @Override
    public void start(Stage primaryStage) {
        Button btn = new Button();
        btn.setText("Submit");
        btn.setOnAction(new EventHandler<ActionEvent>() {
            @Override
            public void handle(ActionEvent event) {
                System.out.println("click...");
        final StackPane root = new StackPane();
        root.getChildren().add(btn);
        final Scene scene = new Scene(root, 300, 250);
        primaryStage.setTitle("Hello World!");
        primaryStage.setScene(scene);
        primaryStage.show();
        Task<Integer> task = new Task<Integer>() {
            @Override
            protected Integer call() throws Exception {
                int iterations;
                for (iterations = 0; iterations < 10000000; iterations++) {
                    if (isCancelled()) {
                        updateMessage("Cancelled");
                        break;
                    updateMessage("Iteration " + iterations);
                    updateProgress(iterations, 10000000);
                return iterations;
        final ProgressIndicator pi = new ProgressIndicator();
        pi.setProgress(ProgressIndicator.INDETERMINATE_PROGRESS); 
        scene.getRoot().mouseTransparentProperty().bind(task.runningProperty());
        Thread th = new Thread(task);
        th.start();
        task.stateProperty().addListener(new ChangeListener<State>() {
            public void changed(ObservableValue<? extends State> observable, State oldValue, State newValue) {
                if (newValue == State.SUCCEEDED) {
                    root.getChildren().remove(pi);
                } else if (newValue == State.RUNNING) {
                    root.getChildren().add(pi);
    public static void main(String[] args) {
        launch(args);
  

Similar Messages

  • My MacBook Pro will not start. When I started it goes to a gray screen with the Apple logo and has the spinning dial. When I started in safe mode it will not start. In safe mode it as an error message that says MacBook Launch_msg():Socket is not connected

    My MacBook Pro will not start. When I started it goes to a gray screen with the Apple logo and has the spinning dial. When I started in safe mode it will not start. In safe mode it as an error message that says MacBook Launch_msg(): Socket is not connected

    If running 10.7 or later hold down Command-R at Startup.
    This should invoke recovery Mode.
    Choose Disk Utility.
    Select your Hard drive. Inspect the SMART Status in the lower right of the window for "Verified".
    Select the Mac OS X Volume (originally Macintosh HD) click (Repair Disk)
    If errors, run again until it comes clean or gets stuck.
    Report any error messages.

  • To lock the output of a SELECT query

    Hi,
    I want to lock the output of a SELECT query to some transaction.
    I have wriiten it as follows , the output of the query is a single row;
    SELECT empname
    FROM employees
    where empid = 100
    FOR UPDATE;
    Specifying only FOR UPDATE is proper or do i need to specify some more clause ??
    Thanks.

    bscalzo wrote:
    You can also specify the columns to lock if you like:
    select x, y, z from aaa where x = 1 for update of x, y;
    But the locking is still currently only done at the row level - but who knows what the future might offer. May not hurt to have the columns named for thay day when the syntax and engine sync up :)It might be worth to amend that specifying the columns is already particularly relevant if you select from multiple tables/views in order to specify which rows of which table/view to lock.
    Regards,
    Randolf
    Oracle related stuff blog:
    http://oracle-randolf.blogspot.com/
    SQLTools++ for Oracle (Open source Oracle GUI for Windows):
    http://www.sqltools-plusplus.org:7676/
    http://sourceforge.net/projects/sqlt-pp/

  • Updating the GUI from a background Thread: Platform.Runlater() Vs Tasks

    Hi Everyone,
    Hereby I would like to ask if anyone can enlighten me on the best practice for concurency with JAVAFX2. More precisely, if one has to update a Gui from a background Thread what should be the appropriate approach.
    I further explain my though:
    I have window with a text box in it and i receive some message on my network on the background, hence i want to update the scrolling textbox of my window with the incoming message. In that scenario what is the best appraoch.
    1- Shall i implement my my message receiver as thread in which i would then use a platform.RunLater() ?
    2- Or shall i use a Task ? In that case, which public property of the task shall take the message that i receive ? Are property of the task only those already defined, or any public property defined in subclass can be used to be binded in the graphical thread ?
    In general i would like to understand, what is the logic behind each method ?
    My understanding here, is that task property are only meant to update the gui with respect to the status of the task. However updating the Gui about information of change that have occured on the data model, requires Platform.RunLater to be used.
    Edited by: 987669 on Feb 12, 2013 12:12 PM

    Shall i implement my my message receiver as thread in which i would then use a platform.RunLater() ?Yes.
    Or shall i use a Task ?No.
    what is the logic behind each method?A general rule of thumb:
    a) If the operation is initiated by the client (e.g. fetch data from a server), use a Task for a one-off process (or a Service for a repeated process):
    - the extra facilities of a Task such as easier implementation of thread safety, work done and message properties, etc. are usually needed in this case.
    b) If the operation is initiated by the server (e.g. push data to the client), use Platform.runLater:
    - spin up a standard thread to listen for data (your network communication library will probably do this anyway) and to communicate results back to your UI.
    - likely you don't need the additional overhead and facilities of a Task in this case.
    Tasks and Platform.runLater are not mutually exclusive. For example if you want to update your GUI based on a partial result from an in-process task, then you can create the task and in the Task's call method, use a Platform.runLater to update the GUI as the task is executing. That's kind of a more advanced use-case and is documented in the Task documentation as "A Task Which Returns Partial Results" http://docs.oracle.com/javafx/2/api/javafx/concurrent/Task.html

  • Service for vf02 permanently locks the invoice number

    Hi,
    I have created one service for VF02 transaction as given in this path:
    default_host
    --->sap
    --->bc
    --->gui
    --->sap
    --->its
    --->VF02
    I am calling this service in an external window browser from my Web Dynpro application.
    Problem is => if I cloase the browser window by using close button, it permanently locks the invoice number used.
    How to resolve this?
    Thanks
    -Haresh

    Hi,
    Use ~SINGLETRANSACTION=1 parameter on your ITS service. This parameter closes your invoice properly.
    Hope this helps,
    Iván.

  • How to lock the size of front panel so that user can't see hidden objects?

    Dennis_Knutson wrote:
    You don't care that the code itself can be changed?
    For that you can lock the VI with a password 

    2014spring wrote:
    Sam,
    I'm also considering your advice to redesign it...That's a little pain though.
    Regards,
    spring.
    Hmmm, Thats a really good idea!  a key thought for you:
    Protect the user from himself!  your exe should NEVER display the Front Panel of a non-running vi.  That data can't be updated or renewed - it contains no information the user could possibly be interested in.  Really, that's the mindset you need while refactoring the app!  Some other RUNNING utility may need to display information simillar to that shown on the vi FP in question but "Dead Data" is about the worst thing you can give to a user.  (I've had simillar "Face-Palm" moments - don't feel too bad)

  • Controlling a thread from the gui

    Hi ive written a small piece of code that demonstrates the problem im having:
    package Util;
    import java.awt.FlowLayout;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    public class Monitor implements ActionListener {
         Mon mon = new Mon();
         public Monitor() {
              JFrame frame = new JFrame();
              JButton start = new JButton("Start");
              JButton pause = new JButton("Pause");
              pause.addActionListener(this);
              start.addActionListener(this);
              frame.setLayout(new FlowLayout());
              frame.add(start);
              frame.add(pause);
              frame.setVisible(true);
              frame.pack();
         public void actionPerformed(ActionEvent e) {
              if (e.getActionCommand() == "Start") {
                   mon.start();
              } else {
                   mon.pause();
         public static void main(String args[]) {
              new Monitor();
    class Mon extends Thread {
         public void run() {
              while (true) {
                   System.out.println("Running...");
                   try {
                        sleep(1000);
                   } catch (InterruptedException e) {
                        e.printStackTrace();
         public synchronized void pause() {
              try {
                   wait();
              } catch (InterruptedException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
    }I was wondering whether anyone could help me fix this or point out where im going wrong. Whenever the pause button is pressed, i want the thread to temporarily stop printing out "Running" until start is pressed again. At the mo, when i press the pause button, the gui locks up and the thread continues to print out running.
    Cheers.

    Thanks da.futt your advice helped me solve the problem, working example:
    package Util;
    import java.awt.FlowLayout;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    public class Monitor implements ActionListener {
         Mon mon = new Mon();
         public Monitor() {
              JFrame frame = new JFrame();
              JButton start = new JButton("Start");
              JButton pause = new JButton("Pause");
              pause.addActionListener(this);
              start.addActionListener(this);
              frame.setLayout(new FlowLayout());
              frame.add(start);
              frame.add(pause);
              frame.setVisible(true);
              frame.pack();
         public void actionPerformed(ActionEvent e) {
              if (e.getActionCommand() == "Start") {
                   try {
                        mon.start();
                   } catch (Exception ex) {
                        mon.restart();
              } else {
                   mon.pause();
         public static void main(String args[]) {
              new Monitor();
    class Mon extends Thread {
         private boolean running = true;
         public void run() {
              while (true) {
                   if (running) {
                        System.out.println("Running...");
                        try {
                             sleep(1000);
                        } catch (InterruptedException e) {
                             e.printStackTrace();
                   } else {
                        synchronized (this) {
                             try {
                                  wait();
                             } catch (InterruptedException e) {
                                  // TODO Auto-generated catch block
                                  e.printStackTrace();
         public void restart() {
              running = true;
              synchronized (this) {
                   notify();
         public void pause() {
              running = false;
              synchronized (this) {
    }

  • My macbook pro will not start up. stuck on grey loading screen and spinning dial. HELP

    my macbook pro will not start up. stuck on grey loading screen and spinning dial. i shut it down last night and now when i try to turn it on it will not get past this page. lights and sounds work but nothing happens. please help

    Power it down by holding the power button down. Then try to power it up again. Post back. It would help if we knew what OS you are running, the model MBP...

  • HT3964 os does not boot beyond spinning dial

    On reboot, and after the MAC icon disappears, my intel imac is stuck on a spinning dial against a white background. What is my next step?

    Take each of these steps that you haven't already tried. Stop when the problem is resolved.
    Step 1
    The first step in dealing with a boot failure is to secure your data. If you want to preserve the contents of the startup drive, and you don't already have at least one current backup, you must try to back up now, before you do anything else. It may or may not be possible. If you don't care about the data that has changed since your last backup, you can skip this step.   
    There are several ways to back up a Mac that is unable to boot. You need an external hard drive to hold the backup data.a. Boot into Recovery by holding down the key combination command-R at the startup chime, or from a local Time Machine backup volume (option key at startup.) Release the keys when you see a gray screen with a spinning dial. When the OS X Utilities screen appears, launch Disk Utility and follow the instructions in the support article linked below, under “Instructions for backing up to an external hard disk via Disk Utility.”
    How to back up and restore your files
    b. If you have access to a working Mac, and both it and the non-working Mac have FireWire or Thunderbolt ports, boot the non-working Mac in target disk mode by holding down the key combination command-T at the startup chime. Connect the two Macs with a FireWire or Thunderbolt cable. The internal drive of the machine running in target mode will mount as an external drive on the other machine. Copy the data to another drive. This technique won't work with USB, Ethernet, Wi-Fi, or Bluetooth.
    How to use and troubleshoot FireWire target disk mode
    c. If the internal drive of the non-working Mac is user-replaceable, remove it and mount it in an external enclosure or drive dock. Use another Mac to copy the data.
    Step 2
    Press and hold the power button until the power shuts off. Disconnect all wired peripherals except those needed to boot, and remove all aftermarket expansion cards. Use a different keyboard and/or mouse, if those devices are wired. If you can boot now, one of the devices you disconnected, or a combination of them, is causing the problem. Finding out which one is a process of elimination.
    If you've booted from an external storage device, make sure that your internal boot volume is selected in the Startup Disk pane of System Preferences.
    Step 3
    Boot in safe mode.* The instructions provided by Apple are as follows:
    Shut down your computer, wait 30 seconds, and then hold down the shift key while pressing the power button.
    When you see the gray Apple logo, release the shift key.
    If you are prompted to log in, type your password, and then hold down the shift key again as you click Log in.
    Safe mode is much slower to boot and run than normal, and some things won’t work at all, including wireless networking on certain Macs.
    The login screen appears even if you usually log in automatically. You must know your login password in order to log in. If you’ve forgotten the password, you will need to reset it before you begin.
    *Note: If FileVault is enabled, or if a firmware password is set, or if the boot volume is a software RAID, you can’t boot in safe mode. Post for further instructions.
    When you boot in safe mode, it's normal to see a dark gray progress bar on a light gray background. If the progress bar gets stuck for more than a few minutes, or if the system shuts down automatically while the progress bar is displayed, your boot volume is damaged and the drive is probably malfunctioning. In that case, go to step 5.
    If you can boot and log in now, empty the Trash, and then open the Finder Info window on your boot volume ("Macintosh HD," unless you gave it a different name.) Check that you have at least 9 GB of available space, as shown in the window. If you don't, copy as many files as necessary to another volume (not another folder on the same volume) and delete the originals. Deletion isn't complete until you empty the Trash again. Do this until the available space is more than 9 GB. Then reboot as usual (i.e., not in safe mode.)
    If the boot process hangs again, the problem is likely caused by a third-party system modification that you installed. Post for further instructions.
    Step 4
    Sometimes a boot failure can be resolved by resetting the NVRAM.
    Step 5
    Launch Disk Utility in Recovery mode (see step 1.) Select your startup volume, then run Repair Disk. If any problems are found, repeat until clear. If Disk Utility reports that the volume can't be repaired, the drive has malfunctioned and should be replaced. You might choose to tolerate one such malfunction in the life of the drive. In that case, erase the volume and restore from a backup. If the same thing ever happens again, replace the drive immediately.
    This is one of the rare situations in which you should also run Repair Permissions, ignoring the false warnings it may produce. Look for the line "Permissions repair complete" at the end of the output. Then reboot as usual.
    Step 6
    Boot into Recovery again. When the OS X Utilities screen appears, follow the prompts to reinstall the OS. If your Mac was upgraded from an older version of OS X, you’ll need the Apple ID and password you used to upgrade.
    Note: You need an always-on Ethernet or Wi-Fi connection to the Internet to use Recovery. It won’t work with USB or PPPoE modems, or with proxy servers, or with networks that require a certificate for authentication.
    Step 7
    Repeat step 6, but this time erase the boot volume in Disk Utility before installing. The system should automatically reboot into the Setup Assistant. Follow the prompts to transfer your data from a backup.
    Step 8
    If you get this far, you're probably dealing with a hardware fault. Make a "Genius" appointment at an Apple Store to have the machine tested.

  • Service for vf02 locks the invoice number

    Hi,
    I have created one service for VF02 transaction as given in this path:
    default_host
           --->sap
                   --->bc
                          --->gui
                                  --->sap
                                          --->its
                                                 --->VF02
    I am calling this service from my Web Dynpro application.
    But the problem is => if I cloase the window by using close button, it locks the invoice number used permanently.
    How to resolve this?
    Thanks
    -Haresh

    Hi Suman,
    I am calling Service for VF02 from Web Dynpro application as an external window, so definitely it'll lock the invoice.
    So when I close that window by close button of browser, it should unlock the invoice number, but it is not releasing the lock.
    I think It is not required to code any unlocking logic in my web dynpro application as I am opening this service in external window.
    Any further help will be appreciated.
    Thanks
    -Haresh

  • Can I create a scroll field/spin dial in Captivate 7 or 8?

    Hi Captivate Superheroes!
    I need to create a scroll field (or spin dial) in a Captivate 7 or 8. Just think iOS scrolling fields, or when choosing an option from a field in many mobile sites. Is it possible to create in Captivate 7 or 8, and if so, how?  Thanks in advance for your support!
    - Rynotrain

    You shouldn't have to do anything "special" other than provide connectivity between the two databases.
    Have you tried creating the database link yet? If so, did you receive errors? If not, then try it out and find out for yourself.

  • Spinning dial in iPhoto

    I have a Macbook OS X 10.6.8 & was trying to upgrade my iPhoto to 9.2.3 all I am getting in iPhoto is the spinning dial.
    Looking for ideas on what to do?

    Is iPhoto the only application that is slow? Or are other applications also having problems?  How much free storage do you have?
    Did the slowness start suddenly or gradually?  Can you remember what you did last, before the problem first occurred?
    Slowness in iPhoto can be caused by several reasons: The most common reasons are
    Lack of free storage. If your Hard Drive is filling up and you have less than 10 GB  left, free storage asap.
    A corruption of your Photo library. Try to repair or rebuild the iPhoto library:   iPhoto 6 and later: Rebuilding the iPhoto library
    Currupted media files in your iPhoto Library. If the problem started after you imported new videos or photos, remove the last import from your iPhoto Library.
    Storing the library on a network volume.
    Instaling incompatible software, that modifies the system. 
    To find out, if the problem is caused by your iPhoto Library, test with a new iPhoto Library.  Is iPhoto more responsive, if you create a new library with a few test photos?
    To check, if the problem is system wide, sign into a different user account and launch iPhoto using that account. Is iPhoto more responsive, if you work from a different user account?

  • Waiting on a user's response (from the gui)

    This should be a really simple problem, but I can't work it out.
    I have two classes, my Engine and my Gui. The Engine tells the Gui what to display, the gui displays it and has methods to fire events when a user presses a button. I want to do something like the following
    public class Engine {
      Gui gui;
      String[] pictures;
      // ... a bunch of stuff
      public void showPictures {
        for (int i=0; i<pictures.length; i++)
          gui.showPicture(pictures);
    // wait on the user's response
    Here's the question: preferably without using threading (though I could if I had to), how can I wait on a user's response from within a loop?
    I considered having a boolean flag "hasResponded" in the gui, and then having a do-while loop just spinning until it saw that gui.hasResponded was equal to true, but it seems that this would add a lot of unnecessary processing load.
    Any thoughts?
    Thanks!

    don1983p wrote:
    I have the same question "So question is still just the simple one above: can I (easily) wait on some event, like the gui recording an action or anything else, from within a loop?"...If you have a question to ask, do so in a new thread. Don't resurrect a long-dead thread. Sure you can refer to it and even link to it, but let it rest in peace.
    Any new ideas?Why would you expect the answer to change? You don't do this via a loop as GUIs don't work like this. Have you gone through the Swing tutorials? If not, please go through them as they'll show you how to do this correctly.
    I wrote a WHILE loop, the condition of the loop being the values (getActionCommand) of some buttons being pressed. How can I wait for another button being pressed so I can get out of the loop?You don't. If you need to time a response, then use a Swing Timer. But most importantly, read the Swing tutorials.

  • Is it possible to seperate an ActiveX control from the GUI thread?

    I have an activeX control (*ocx) that we use for communicating with external instruments. We are running into some difficulty because if the communication with the instrument is held up it can take up to 30 seconds to timeout and our LabVIEW user interface is frozen in the mean time. The VI that contains the control itself does not have to be visible and all the subVIs that use the ActiveX reference have been set to run in the "instrument" execution system thread, but the GUI still freezes. Its my theory that since the ActiveX control itself is in a container and part of a front panel, all refernces to it must be executed in the GUI thread. I just wanted to confirm that this was the case. Also if anyb
    ody would like to suggest any work arounds, feel free. The only idea I've had so far was to move all use of the ActiveX control to external code, which is not a very attractive solution for us.

    ....Also if anybody would like to suggest any work arounds,
    > feel free. The only idea I've had so far was to move all use of the
    > ActiveX control to external code, which is not a very attractive
    > solution for us.
    ActiveX controls are loaded into the UI thread and all interactions with
    them, property nodes, and invoke nodes, have to take place in the UI
    thread/main thread of LV. So, setting the VIs to run in the
    instrumentation or other execution systems, doesn't do much good since
    each call to the property or invoke will just have to switch back.
    What other choices do you have? If the control doesn't have a UI
    anyway, it would improve matters if the control were simply an
    automation server. The automation server can be set to run in a single
    thr
    eaded apartment, or a MT apartment. Changing it to MT means that you
    will have to deal with protecting the code from being called from
    different threads, and having those calls interleaving and competing
    with one another. When you change it to be MT, it can tie up other
    threads in LV and leave the UI thread alone. Another alternative is to
    change the ActiveX control to spin up its own thread and have a method
    that initiates, and one that reads the results or returns the status.
    Greg McKaskle

  • Programmatically lock the IP phone

    Through Google I have searched that some SI companies can develop an application to lock the IP phone. The user needs to type the correct PIN before he/she can dial the number. Is there any API in JTAPI to do so? Or any API in AXL/SOAP?
    Thanks
    Tony

    Hmm.. the way you describe it, you're looking for business account codes rather than a locking mechanism.
    Locking entails that the device must be unlocked before calls can be made... business account codes leave the device accessible for anyone.
    So if you really are looking for device locking, you can build it with AXL.. you need a service to lock / unlock which queries the user's pin (there's an authenticate function in axl to check the pin.. you need CCM5 or higher though), then you'd change the css of the device (e.g. to a css that only allows for internal calls upon locking, and back to the normal css upon unlocking).
    As for account codes.. I think that's in CCM but I'd check the admin guide or the feature and service guide as I've never had the need to use something like that. If it's not there, it certainly can be built as well but it would be cumbersome as you'd either need some kind of IVR along with CTI functionality, or you take away people's ability to dial directly and have them dial from a service.

Maybe you are looking for

  • When you CAN'T buy an album at a time...?

    If there is no BUY tab for an album in iTunes, and instead a VIEW tab only-the entire album cannot be bought at once? You havce to click & bill & pay each song individually? Really??

  • Hp Officejet Pro 8600 Premium - wireless home network printing from multiple devices

    We have a wireless home network with several desk tops, lap tops and tablets using the network for internet access. There is only one printer in the home, our hp Officejet pro 8600 Premium. Right now everyone who has access to the network can print.

  • Test on iPad is free or not ?

    I made it all but how can I test it on my iPad for free ? I tested on the Content Viewer, I posted on my workspace via Folio builder on acrobat.com and verified it, but how can I see it on my iPad ? Do I have to pay a subscription even for my self ?

  • Re: Safari 6.0.5 on OS 10.8.4 doesn't work anymore.

    I'm also having a problem with Safari.  I am running OS X 10.8.4 and the system locks up if I try to start Safari. The only thing that I can think of is that i've some problem with a popup ad that doesn't want to go away so that I have benn using For

  • CPU 100% RV180W

    Hi there,  We purchased 3 products RV180W.  I have seen two posts reporting the error, unresolved.  I installed the latest firmware available for the RV180W but it remains that the device's CPU is at 100% constantly.  They also appear in the log a lo