Okay, so I've got my menu system up and working from a JFrame. Everything seems to work really well, up until I click the button which starts a canvas. Now what the canvas does is intialize a JFrame which extends Canvas so I can't use a thread. Once the frame is up and running it calls a method which has a while true {} after this I am unable to close the frame. This has never been an issue before when running the canvas application using static void main. How can I fix this issue of the new JFrame not closing?
Answer
How can I fix this issue of the new JFrame not closing?
Don't block the EDT (Event Dispatch Thread) - the GUI will 'freeze' when that happens. Instead of creating an infinite loop, implement a SwingWorker
for long running tasks. See Concurrency in Swing for more details.
No comments:
Post a Comment