• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic