Click here to Skip to main content
15,905,323 members
Home / Discussions / Java
   

Java

 
GeneralRe: Sending file though socket as byte[] Pin
jschell13-Oct-23 7:19
jschell13-Oct-23 7:19 
Question[Solved] Getting and setting a File's all attributes Pin
Valentinor24-Sep-23 22:47
Valentinor24-Sep-23 22:47 
AnswerRe: Getting and setting a File's all attributes Pin
Victor Nijegorodov24-Sep-23 23:04
Victor Nijegorodov24-Sep-23 23:04 
GeneralRe: Getting and setting a File's all attributes Pin
Valentinor24-Sep-23 23:17
Valentinor24-Sep-23 23:17 
Answer[Solution] Re: Getting and setting a File's all attributes Pin
Valentinor25-Sep-23 6:26
Valentinor25-Sep-23 6:26 
QuestionGetting java.lang.RuntimeException: ZeroCode Step execution failed. Details:java.lang.NullP Pin
Member 160852744-Sep-23 5:46
Member 160852744-Sep-23 5:46 
AnswerRe: Getting java.lang.RuntimeException: ZeroCode Step execution failed. Details:java.lang.NullP Pin
Richard Deeming4-Sep-23 21:21
mveRichard Deeming4-Sep-23 21:21 
AnswerRe: Getting java.lang.RuntimeException: ZeroCode Step execution failed. Details:java.lang.NullP Pin
Member 160852744-Sep-23 23:55
Member 160852744-Sep-23 23:55 
GeneralRe: Getting java.lang.RuntimeException: ZeroCode Step execution failed. Details:java.lang.NullP Pin
Member 160852744-Sep-23 23:58
Member 160852744-Sep-23 23:58 
GeneralRe: Getting java.lang.RuntimeException: ZeroCode Step execution failed. Details:java.lang.NullP Pin
Member 160852745-Sep-23 0:09
Member 160852745-Sep-23 0:09 
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 

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.