Over the course of the past few weeks the command button component in Flamingo component suite has been enhanced following the feedback from the project users. There is nothing better than getting the feedback from real-world use, and it is much appreciated on my side. Many thanks go to Kenneth Flynn and Christian Hebert for finding time to report these issues.

Supporting the disabled state

Calling setEnabled(false) on a command button will display the correct disabled state. As with the core AbstractButton, you can set a disabled icon with setDisabledIcon API. The helper org.jvnet.flamingo.common.icon.FilteredResizableIcon class can be used to wrap an existing resizable icon with a ColorConvertOp based on ColorSpace.CS_GRAY (core JDK functionality). Here is a screenshot of a few command buttons in enabled state:

And here are the same buttons in disabled state. Note how the visuals are changed to reflect the new state (including the foreground color of the main text and the extra text, as well as the popup arrow icon). The buttons in the first column specify a custom disabled icon (with the APIs mentioned above).

Supporting changing the text

Previously, once a command button has been created, it was not possible to change its display text with the setText(String) API. The new version supports this API, tracking the display text and recomputing the strings under the BIG and CUSTOM states as necessary. Here is a screenshot of a few command buttons with the default “Click!” text:

And here are the same buttons after they have been clicked a number of times. Each button has an action listener that counts the number of clicks and updates the button text accordingly. Note how the displayed text and the preferred size of the buttons are changed (automatically):

Supporting changing the font

Previously, the command button would ignore setting a custom font with setFont(Font) API. The new version supports this API. Here is a screenshot of a few command buttons using a custom italic font:

Support auto-repeat action mode

The auto-repeat action mode comes in handy when you want to have the action listeners invoked every N milliseconds as long as the button is pressed. This functionality is present, for example, on the arrow buttons in the core scroll bars. Once the scroll arrow button is pressed, it starts firing the scroll action events every 60 milliseconds after the initial delay of 300 milliseconds.

The JCommandButton component has two new APIs to support the auto-repeat action mode. Use the setAutoRepeatAction(true) to set the auto-repeat action mode on. The default initial delay is 500 milliseconds and the default subsequent delay is 100 milliseconds. To change the default values, call setAutoRepeatActionIntervals(int, int) API.

Support column-fill mode on command button panel

Previously, the command button panel component only supported row-fill mode. Under this mode, the buttons are placed in row-first fashion, wrapping the rows when the panel width is reached. Now, the component also supports the column-fill mode. Use the setLayoutKind(LayoutKind) API to specify the layout mode. Here is a screenshot of a command button panel with the default row-fill mode (note the vertical scroll bar):

and here is the same panel under the column-fill mode (notice the horizontal scroll bar):

This functionality is available in the latest 3.1dev drop of Flamingo.

The new Extras pack for Substance look-and-feel provides additional settings on top of the functionality available in the core library. The previous entry showed screenshots of color schemes, watermarks and skins from the Extras pack, and this entry will talk about button shapers, mixed color scheme and mixed gradient painters.

Additional button shapers can be found in the <font color="darkblue">org.jvnet.substance.shaperpack</font> package. The screenshot below shows the available button shapers.

The <font color="darkblue">org.jvnet.substance.colorschemepack.MixColorScheme</font> provides support for creating a color scheme based on more than one base color schemes. The <font color="darkblue">org.jvnet.substance.painterpack.gradient.MixDelegateGradientPainter</font> allows wrapping an existing gradient painter to support mixed color schemes. The sample screenshot from the Mango skin (note the painting of scroll bar thumbs, checkmarks of radio buttons and checkboxes and the top part of the selected tab):

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

  • Jacek Furmankiewicz has announced the first beta release 0.1 of his SwingBuilder project. It provide support for data binding with Beans Binding, layout management with MigLayout, validation with Apache Commons Validator, long running tasks with SwingWorker and has integration libraries for JIDE and SwingX.
  • Maxim Zakharenkov has released version 1.2 of the Swing Explorer tool for debugging Swing applications. Eclipse support is a welcome addition, and in fact i would warmly recommend rewriting the entire UI as a collection of Eclipse views. In my experience, Eclipse is a great scaffolding for exactly this kind of information presentation, taking away a lot of implementation complexity and leaving you with implementing your actual logic. As long as you don’t fight it and try to go against the “Eclipse way” of doing things, you’ll find it a very mature and rich platform. In addition, learning another UI toolkit (SWT) is not a bad thing.
  • Collin Fagan writes about using tooltips to show preview of tabs in a tabbed pane. Users of Substance look-and-feel had access to this functionality for quite some time now, and Collin shows how this can be done in a cross-LAF way.
  • Ayman Al-Sairafi is working on the JSyntaxPane component that provides a text control with syntax highlighting for Java, Groovy, XML and JavaScript. It follows in the footsteps of jEdit Syntax package and Apache Batik XML editor kit (contributed by Kiyut) and is available under the Apache license.
  • There’s a new Swing book out there! Tim Lavers and Lindsay Peters have written a book “Swing Extreme Testing” published by Packt Publishing. From the book site – This book is a practical guide to automated software testing for extreme Java programming using Swing GUIs, with lots of ready-to-use real-life examples and source code for automated testing of the software components usually regarded as too hard to test automatically.
  • David Qiao and Wolfgang Zitzelsberger have announced integration between JIDE components and Synthetica look-and-feel.
  • Richard Kennard has announced release 0.5 of the Metawidget project that takes domain objects in your applications and creates the UI widgets for them. It has support for SwingX, GWT, Groovy and applets.
  • Andy Maleh introduces the Glimmer project that aims to create a JRuby DSL for creating cross-platform UIs with SWT.
  • Peter Karich kicks off the series of articles on Spring Rich Client Project. Unlike server-oriented Spring projects, this has not seemed to receive nowhere as many resources to be actively targeting the major paint-points of rich client development. Answering the “when will 1.0 be released” with “when it’s ready” is not a good sign, and one of the commenters says that the plans are to rebrand it to Spring Desktop without “being bound to the current codebase”. If you’re planning to break backwards compatibility and have good reasons to do so – just say it as it is.
  • David Qiao writes about adding arrow key support to the ButtonPanel component. Alexander Potochkin had a similar functionality in the JXButtonPanel a couple of years ago.
  • Rajesh has a list of ten free docking frameworks for Java UI applications. One addition to the list comes from Davide Raccagni that has announced the new P74 graphical library. It contains a docking manager as well as a few other tools.

Substance Extras pack

June 21st, 2008

As specified in the roadmap for version 5.0 of Substance look-and-feel, a number of the existing Substance plugins have been consolidated into the Extras pack. This pack contains additional color schemes, watermarks and skins, as well as a mixed color scheme and a mixed gradient painter. The documentation for the Extras pack contains the information about the available features, and you can run the WebStart application below and select the skins from the “Skins” menu.

The plugin itself can be downloaded here, and once you add it to your classpath, the new skins will be available to the applications via the existing Substance APIs. Here are some screenshots of additional color schemes availablein the Extras pack:

Here are a few additional watermarks available in the Extras pack. Note that in version 4.3 these were available in the core distribution. Since using watermarks introduces about 25-45% performance overhead, these have been moved from the core library.

And here are the additional skins