0

I have a function that connects to a data base, get some data, and alter my pane using the data.

i want this function run after i enter the reference to the query in the background and let the user continue filling other details.

java.lang.IllegalStateException: Not on FX application thread; currentThread = Thread-6

i used a thread and keep getting this error.

what i have found so far: i found that many people says to use a run later function. using this function does the job, but not par alley. it waits for the function to complete the execution to let the user continue.

how can i fix this problem.

Eshaka
  • 974
  • 1
  • 14
  • 38
  • 2
    the error tells you all, doesn't it? Which is: you __must not__ change any property of any node in an active scenegraph off the fx application thread. Have a look at concurrency support in javafx. When still stuck, come back with a [mcve] (mock the database) demonstrating the problem. – kleopatra Mar 31 '20 at 08:05

1 Answers1

3

I'm assuming that most of the time taken by the function is for the database connection, and not for editing the pane.

You are having Not on FX application thread error because you're trying to change FXML elements in another thread, You can use run later functions just only for change the pane.

What you can do is do your database things in another thread and create a run later function for FXML elements. Hopefully that will speed up the process.