This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Hands On Software Engineering with Python and have Brian Allbey on-line!
See this thread for details.
Win a copy of Hands On Software Engineering with Python this week in the Jython/Python forum!

Andrey Mironov

Greenhorn
+ Follow
since Jan 09, 2019
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
2
Given in last 30 days
2
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Andrey Mironov

Knute Snortum wrote:Platform.runLater() does "run later," but the tasks to run later are put into the queue one after another.  That's why you can have two "run laters" and be guaranteed they will run one after the other.



A solution with two Platform.runLater() really worked. It is a pity that it did not occur to me before.

Thanks for the help!
4 days ago

Knute Snortum wrote:Do you specifically want a certain GIF to show you're task is busy...?


Yep, GIF should run over the program window while the program code is being executed. Like this:


I followed your advice and wrapped 'Platform.runLater (() -> showGif ())' into Runnable. I tried to place it directly in the Event Handler - the result is the same, the GIF runs only after all the main code. Although, logically, it should be launched in parallel - a separate thread is running.



Then I again decided to use my previous approach with the launch in main of an infinite loop that checks the 'isStarted' status of the button. Instead of Task set Runnable. Did not help. Again, first the code - then gif.



How to make them work at the same time?
5 days ago
Salute.

I apologize in advance for a lot of text, but I come back to this problem the second day and tried several solutions, plus I did not receive a working answer on stackoverflow.  So - I hope for help here.

Essence: on the GUI (JavaFX) there is a button that should launch two processes: the main program code (about 2 seconds) and the wait gif, which runs on top of the GUI.  Accordingly, when the code is executed - the GIF is completed.

What I have done now:
The button's action method blocks the isStarted flag, which gets true when the button is pressed and false after the completion of the main code.  In the main, before launching the GUI, I created a Task, which checks the flag in an infinite loop and, as soon as it gets true, it starts my gif with a separate showGif() method.

Main:



Button:

 
showGif():





Result: the stream starts before the main code, the cycle is spinning, the GIF does not open  - showGif() method stops at pane.setCenter(hb) .  I added Platform.runLater() before calling the showGif() method in Task:




Now the cycle works completely, but the showGif() method is executed only after all the main code.  GIF opens, but no longer needed.


I also tried the call to the showGif() method via Platform.runLater() directly in the button method, without any cycles, flags and Tasks - the result was the same (the GIF starts, but at the end of the program.)  I added three seconds of delay to the main code, in case the GIF just didn't have enough time - the result is the same.

Tell me what am I doing wrong?  I don't see the options.
1 week ago