Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

I have problem with GUI which freeze while I run a long task  RSS feed

 
panumarch anantachaiwanich
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can I solve this problem?

I try to show picture continuously(like video) by Thread in GUI

and I create STOP button to stop thread

but it doesn't work(all button is freeze there's just image showing after I press START.)



Thread code


START & STOP code



I'm using Netbeans and I'm beginner.

Please help me. Thank you very much.

[ January 02, 2009: Message edited by: panumarch ananta ]
[ January 02, 2009: Message edited by: panumarch ananta ]
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to take a gander at this and then look into using something like SwingWorker for long running tasks.

[Rob] Fixed the link [/]
[ January 02, 2009: Message edited by: Rob Prime ]
 
panumarch anantachaiwanich
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much for your suggestion.

I try SwingWorker many times, but I don't understand how to use it.

Please give me the solution for my code.

Thanks again.
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know what you mean exactly by this
"I try to show picture continuously.."

if you mean a type of slide show (one pic after the other, at intervals),
just use a swing.Timer - it does all the behind-the-scenes threading for you
 
panumarch anantachaiwanich
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry that I'm not good at English.


I mean that I want to show many pictures like video.

I'm making project using webcam.

I'll grab frame from webcam to .jpg then process and show it instantly.


Thanks you.
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24215
37
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Note that to run a thread, you do not call run(); you call start(). By calling run() directly, you're invoking your drawing code directly on the event thread, which block actual screen updating from ever happening. So your action event handler should be calling start().
 
panumarch anantachaiwanich
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you everyone very much.

The solution is so easy that I can't believe it.

Sorry that at first I don't explain clearly.


I just registered to this forum, and everyone try to answer me instantly.

I love this forum very much. It make my work has more progress. Thanks.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!