Auto-scrolling is a feature that can be found in most mainstream modern applications. Pressing the middle mouse button transfers the application into the auto-scrolling mode. In this mode, moving the mouse down starts scrolling down the contents even when the mouse is no longer moving. The scroll speed depends on the distance between the current mouse location and the mouse press location. This works for all four directions (up, down, left, right).

There are two existing Swing implementations that i’m aware of:

Both approaches have their drawbacks. The first one effectively changes the UI hierarchy and the second one uses a global frame resource, effectively resulting in repainting the entire UI on every scroll (even when the scroll pane is a small part of the application).

Christopher Deckers has already appeared as a guest author on this blog, and he was very helpful during the development cycles of last two versions of Substance look-and-feel. He has found numerous bugs (many thanks) and made numerous suggestions for enhancing existing features and adding new ones (many thanks). One of his “most wanted” features was the support for auto-scrolling, and after a few iterations he has contributed an elegant implementation that does not use a global resource and does not change the UI hierarchy.

The new LafWidget.AUTO_SCROLL client property can be installed on a specific scroll pane or globally on the UIManager. Once it is set to Boolean.TRUE, the corresponding scroll pane(s) will have the auto-scroll mode installed on them. There are two operation modes:

  • Press the middle mouse button and release it. The scroll pane is transferred into the auto-scroll mode. It can be dismissed by clicking the mouse or scrolling the mouse wheel.
  • Press the middle mouse button and start dragging. The auto-scroll is dismissed by releasing the middle mouse button.

The implementation itself installs a mouse listener on the scroll pane, and when the middle mouse button is clicked, it shows the auto-scroll icon wrapped in a popup menu (thus no need for glass pane). In addition to showing the menu, it also installs a global AWTListener that listens to mouse wheel and mouse move events, scrolling the pane as necessary.

This is the last new feature that was added to the version 4.3 of Substance. It is now in feature freeze state. The release candidate is scheduled on March 31st, with the final release scheduled on April 14.

A little update

March 20th, 2008

My last entry on customer service has attracted a stray attention, and the main blog page was broken for a few hours today. Following this, i have deleted that entry along with the its comments – apologies to the readers. I have also deleted all registered users and disabled new user registration – apologies for the inconvenience. Comments on existing and future posts are left enabled for now.

The java.net site has just published my article on translucent and shaped windows, and it is one of the reasons why i have been a little quite on this blog. The two previous entries have shown simple usages of the shaped and translucent windows:

While this has a lot of potential, it is not immediately clear how it can be applied to the real-life Swing programs. The java.net article tries to explore this area a little bit further and touches on three examples:

  • Translucent heavyweight tooltips
  • Fading heavyweight tooltips
  • Real time translucent reflection on a top-level window

The fading tooltip is my favorite at the moment. It shows the true potential of this functionality in providing a smooth user experience, especially in the context of modern UIs that use rollover and selection fades. The real time video reflection is also quite interesting, especially for the “coolness” factor.

The full sources can be found in the CVS repository of the companion PushingPixels java.net project.

If you have more ideas for window translucency, let me know in the comments.

Here are some Swing links that you might have missed during this week:

  • Thierry Lefort published an update to the lazy loading tree. It now includes a single expansion listener and better model / controller separation.
  • Alex Ruiz will present a JavaOne session with Yvonne Price. It will talk about GUI testing and their FEST library.
  • Jeff Friesen has an overview article about the AnimatingCardLayout project that provides animations on top of a usual core card layout. I have already blogged about the various approaches to the layout animation, and the last year hasn’t changed my opinion. These are nice to have, but almost never used. An important note on the specific project – it has been inactive since December 2004, so if you find a bug or want to file an enhancement, you’re on your own (the project license is BSD).
  • Christopher Deckers announces release 0.9.4 of DJ Native Swing library. This brings improvement to stability and two new components, JVLCPlayer and JHTMLEditor.
  • Christophe Le Besnerais writes about his experiments in colorizing Swing UIs. The code has an interesting twistin that it allows colorizing only some parts of the interface.
  • Pavan Kumar explores a technique of showing progress without blocking the entire UI. Building on the previous work by Alexander Potochkin, it is a nice idea, but i found that the test application is not working as expected. While the table is indeed not blocked by the tree and shows that a selected cell is editable, i couldn’t type anything in until the tree was unblocked.
  • Dave Cherry is working on wrapping the JFreeChart library in a Groovy builder. The code is being developed on top of the GroovyChart library.
  • Andres Almiray has a busy Groovy week. He announced release 0.5 of his GraphicsBuilder library and also published the fourth part of the Groovy Zone tutorial.

Finally, quote of the week belongs to James Gosling:

Even though it’s a Java game, it’s only available for Windows and OS X – they use QuickTime for Java. (we’re trying to get our cross-platform media story together, but it’s tough… [codecs are easy, we’ve got piles of them: it’s all about patent royalties on free software :-( ])

Let’s compare this with QT Jambi:

Qt and Qt Jambi 4.4 gets full-blown multimedia support through the Phonon framework adopted from KDE. This gives easy access to playing and manipulating movies and music in all the nice file formats for which the underlying media framework has codecs. The framework defaults to using Gstreamer (Linux), Microsoft DirectShow (Windows) and Quicktime (Mac OS X).

So, another cross-platform UI toolkit is showing that it can be done and that it will be officially released this year