Web Analytics Made Easy -
StatCounter java - GUI stops repainting - CodingForum

Announcement

Collapse
No announcement yet.

java - GUI stops repainting

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • java - GUI stops repainting

    I've created a small GUI application that animates the solution to the Towers of Hanoi problem.
    The user can enter the number of disks and time delay.

    Everything works with one major issue.
    After the "start" button is clicked and the animation begins the UI is vulnerable to damage. i.e. If I drag another window over top or minimize the window the UI dissappears or gets "erased"...

    the animation of the disks still draws inside the panel I use as a display, but every other part of the screen can be erased.

    after the animation is complete, everything redraws correctly again.

    how do I have the UI repaint properly during the animation process?

    Thanks,

    Yak

    - there is quite a bit of code, so if anybody thinks they can help or wants to take a look at it, I can attach it to my next post.

  • #2
    Can you use threading in Java? I haven't done any Java programming in a bit.

    It sounds like there is one thread running for your entire application and this thread does the work for your app. So while it is calculating the solution to the problem, it isn't devoting any time to keeping the GUI drawn.

    If you create a thread to handle the calculations that is seperate from the main thread, then both the GUI drawing and the other stuff can occur at the same time and that should fix your problem.

    If I am off base, someone feel free to correct me.

    Comment


    • #3
      Fatmumuhomer,

      That is exaclty what I was thinking, however I have no idea how to go about using threads...currently reading into come tutorials on the sun website.

      Any suggestions would be greatly appreciated.

      Thanks

      Yak

      Comment


      • #4
        Resolved, using threads.

        thanks,

        Yak

        Comment

        Working...
        X