Click here to Skip to main content
15,886,919 members
Home / Discussions / Java
   

Java

 
GeneralRe: Getting java.lang.RuntimeException: ZeroCode Step execution failed. Details:java.lang.NullP Pin
Richard MacCutchan5-Sep-23 0:21
mveRichard MacCutchan5-Sep-23 0:21 
AnswerRe: Getting java.lang.RuntimeException: ZeroCode Step execution failed. Details:java.lang.NullP Pin
jschell5-Sep-23 2:34
jschell5-Sep-23 2:34 
GeneralRe: Getting java.lang.RuntimeException: ZeroCode Step execution failed. Details:java.lang.NullP Pin
Member 160852745-Sep-23 5:11
Member 160852745-Sep-23 5:11 
GeneralRe: Getting java.lang.RuntimeException: ZeroCode Step execution failed. Details:java.lang.NullP Pin
Richard Deeming5-Sep-23 21:23
mveRichard Deeming5-Sep-23 21:23 
GeneralRe: Getting java.lang.RuntimeException: ZeroCode Step execution failed. Details:java.lang.NullP Pin
Richard MacCutchan5-Sep-23 22:43
mveRichard MacCutchan5-Sep-23 22:43 
QuestionWhat is the difference between a static and an instance variable in Java? Pin
Ashley OP7-Aug-23 23:31
Ashley OP7-Aug-23 23:31 
AnswerRe: What is the difference between a static and an instance variable in Java? Pin
Richard MacCutchan7-Aug-23 23:33
mveRichard MacCutchan7-Aug-23 23:33 
QuestionJavaFX multithreading operation changing GUI elements Pin
JohnCodding21-Jul-23 6:37
JohnCodding21-Jul-23 6:37 
I want to make it so that when the user launches the app, it will display the GUI but at the same time it will launch other threads (multithreading) that will do some calculations and when those are finished they will update some GUI elements (which are always created before the thread with calculations is launched, that is not a problem of getting null), also when a button is pressed same as before using multithreading it will do some calculation and update the GUI after each thread is done.

Now the problem I have is that if you are using Thread(new Runnable)/start(); to launch multiple threads (even one) you get into the error Not on FX application thread. As possible solutions I read about JavaFX Task and Service but those were freezing the GUI thread until they were done.

This is what I tried ("Functions.functionX" is the placeholder, the real function takes between 0-20 seconds to finish):
button.setOnAction(event -> {
    Service<Void> doSomething = new Service<Void>() {
        @Override
        protected Task<Void> createTask() {
            Functions.functionX("parameter");
            return null;
        }
    };
    doSomething.start();
});

Now the problem with this is like I said, when the button is pressed, the GUI is unusable until the function finishes. Using straight Task had the same effect unfortunately.
What do I need to change/add to make it so that I can launch multiple threads at a time, and inside them to change elements from GUI (right now I only want to update some Labels with .setText() inside those threads, each thread updates one Label)?

modified 21-Jul-23 13:02pm.

AnswerRe: JavaFX multithreading operation changing GUI elements Pin
JudyL_MD21-Jul-23 9:01
JudyL_MD21-Jul-23 9:01 
GeneralRe: JavaFX multithreading operation changing GUI elements Pin
JohnCodding21-Jul-23 9:44
JohnCodding21-Jul-23 9:44 
GeneralRe: JavaFX multithreading operation changing GUI elements Pin
JudyL_MD21-Jul-23 10:46
JudyL_MD21-Jul-23 10:46 
AnswerRe: JavaFX multithreading operation changing GUI elements Pin
JohnCodding21-Jul-23 9:49
JohnCodding21-Jul-23 9:49 
QuestionOperator precedence Pin
darek2902198812-Jul-23 5:41
darek2902198812-Jul-23 5:41 
AnswerRe: Operator precedence Pin
Dave Kreskowiak12-Jul-23 6:11
mveDave Kreskowiak12-Jul-23 6:11 
QuestionOperator precedence Pin
darek2902198811-Jul-23 3:06
darek2902198811-Jul-23 3:06 
AnswerRe: Operator precedence Pin
Richard Deeming11-Jul-23 3:30
mveRichard Deeming11-Jul-23 3:30 
GeneralRe: Operator precedence Pin
darek2902198812-Jul-23 5:44
darek2902198812-Jul-23 5:44 
GeneralRe: Operator precedence Pin
jeron112-Jul-23 6:15
jeron112-Jul-23 6:15 
AnswerRe: Operator precedence Pin
Richard MacCutchan11-Jul-23 5:24
mveRichard MacCutchan11-Jul-23 5:24 
GeneralRe: Operator precedence Pin
darek2902198812-Jul-23 5:46
darek2902198812-Jul-23 5:46 
QuestionRe: Operator precedence Pin
Richard MacCutchan12-Jul-23 6:15
mveRichard MacCutchan12-Jul-23 6:15 
AnswerRe: Operator precedence Pin
Andre Oosthuizen14-Jul-23 1:36
mveAndre Oosthuizen14-Jul-23 1:36 
GeneralRe: Operator precedence Pin
Richard MacCutchan14-Jul-23 1:52
mveRichard MacCutchan14-Jul-23 1:52 
QuestionSign a PDF document in PAdeS format using a CNS (National Services Card) or a SmartCard. Pin
Antonio20238-Jul-23 19:45
Antonio20238-Jul-23 19:45 
QuestionRelative Sorting Pin
Harriet Muduwa26-Jun-23 6:42
Harriet Muduwa26-Jun-23 6:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.