The Source for Java Technology Collaboration
User: Password:



Romain Guy

Romain Guy's Blog

SwingFX: Cancelable Infinite Progress

Posted by gfx on October 06, 2005 at 04:18 PM | Comments (3)

Many months ago, Craig and I started the SwingFX project. One of the first components to be added was the infinite progress panel I described in a blog entry:

SwingFX


This component was quite successful (I've recently seen a variation in ZValley's ZEN) but it remains quite simple. Michael Bushe just added a very valuable feature, the ability to cancel the current running task:

SwingFX


You can get it today in SwingFX binaries, source and documentation. I also suggest you to take a look at the rubberband API, it can prove to be useful in some applications.


Bookmark blog post: del.icio.us del.icio.us Digg Digg DZone DZone Furl Furl Reddit Reddit
Comments
Comments are listed in date ascending order (oldest first) | Post Comment

  • That's a valuable new feature!
    The "cancel" button can be sometimes ulgy, is it currently possible to cancel the running task by simply clicking the infinite progress panel without having the "cancel" button?

    Posted by: poppleton on October 07, 2005 at 03:08 AM

  • This is just the default implementation provided by Michael. You can write your own that would not display a Swing button if you want.

    Posted by: gfx on October 07, 2005 at 03:35 AM

  • Romain is correct. I'm pretty careful to allow extensions to Swing API since good UIs always have lots of customizations and consistency is nice and necessary thing.

    Out of the box, the panel uses a JButton. To use your own button (or whatever you want), derive your own class from CancelableProgessAdapter and pass an instance of your class to InfiniteProgressPanel of PerformanceInfiniteProgressPanel (aka the CancelableAdaptees). In your own CancelableProgressAdapter override:

    protected JButton createCancelButton();

    Be sure to hook up an action listener to the button to call progressPanel.stop(). This method also allows you the "Are you sure you want to cancel?" ability if you want that too. You may want to download the latest as I added some constructors and overridabel methods to make this easier.

    If you want no button at all, return null for the above method and nothing will be drawn. (Download the latest, as I just fixed a NPE that would occur if you tried this).

    Posted by: michaelbushe on October 13, 2005 at 12:54 AM





Powered by
Movable Type 3.01D
 Feed java.net RSS Feeds