7

Threading in Java doesn't work properly with swing,i'm sad..hopefully it will work with Java FX

Comments
  • 1
    It's been a long time since I looked at doing a Java gui, but I don't remember there being a threading issue in swing.

    What are you seeing and what are you expecting?
  • 0
    @psudo I have a vector called bookingsvector that's has a collection of bookings objects loaded from an sqlite database.when I add a booking,thats entered into an sqlite database using a separate jframe(let's call it bookings frame )and the booking was made for today itself.i have a jlist on the main jframe that's supposed to refresh itself and have all the bookings that were schedules for today.im using threads to get into the main jframe and call the method(getBookingsforToday) and refresh the jlist
    The method does actually execute and output is actually given.but the jlist itself stays the same.
  • 0
    @zmzmuazzam98 If those threads you spawned are SwingWorkers in not sure what's wrong.

    But it sounds like you might be trying to use normal threads, which break the swing concurrency model.
  • 0
    @psudo yes I'm using normal threads.i shall try and use swing workers .
  • 0
    @zmzmuazzam98 You might find this tutorial helpful: https://docs.oracle.com/javase/...
  • 1
    May be I misunderstood, but I guess updating views from threads is a challenge in all languages. View always run in the main thread, so you can only update view from the main thread. At least that's the case for JavaScript, and android and iOS.
Add Comment