• 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

HFDP p. 465: Virtual Proxy Pattern better than SwingWorker?

 
Ranch Hand
Posts: 1855
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I realized that the Virtual Proxy described on HFDP pp. 465 is forking a new Thread to conduct the Image Loading so that a Swing GUI will not hang up.

Isn't the hanging up of Swing windows the reason why we have SwingWorker

I honestly doubt now why we should use SwingWorker at all, when we can use a Virtual Proxy which in my mind is much cleaner than SwingWorker.

Let me know what you think :roll:

Regards,
Darya
 
Darya Akbari
Ranch Hand
Posts: 1855
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

more confusing to me is the fact that SwingWorker seems to become one of the Enhancements in Java SE 6 (Mustang).

Really I don't see why not using a Virtual Proxy with it and having one class (SwingWorker) less to care about.

Or am I missing anything .

Regards,
Darya
 
Ranch Hand
Posts: 372
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey Darya, How are you doing?
I donno what this SwingWorker is, but is there a chance that it uses the Virtual Proxy internally for its implementation?
 
Darya Akbari
Ranch Hand
Posts: 1855
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Sathish,

good to hear from you . As far as I know SwingWorker is not using the Virtual Proxy Pattern :roll: .

Regards,
Darya
 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To me, it looks like SwingWorker isn't much more than an abstract class that will make it easier to implement the Virtual proxy pattern.
 
Darya Akbari
Ranch Hand
Posts: 1855
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Martin,

maybe this is the right direction.

See the sample code for the ImageProxy from HFDP p. 465:



Where would you place the SwingWorker in above code? Isn't above code thread safe? What is the benefit using SwingWorker instead of above Virtual Proxy?

Regards,
Darya
 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
SwingWorker is an abstract class that enables you to execute your GUI code on the Event Dispatching Thread easier. It allows you to run a task on a new thread and when that thread returns any GUI updates, the updates are done on the EDT. It helps make your Swing programs more thread safe.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic