Skip to main content

Michael Kneebone on the Laf-Widget Project

Posted by editor on May 18, 2009 at 6:56 AM PDT

This week's java.net Spotlight highlights Michael Kneebone's appearance as guest blogger on Kirill Grouchnikov's Pushing Pixels site. Michael works on the Laf-Widget project (Laf = "Look And Feel"). He has recently extended the project's widgetising support, and writes about its usage and how it works on the inside.

The goal of the Laf-widget project is to "provide support for a base set of additional behaviour and widgets in look-and-feels." The project is currently at release candidate version 4.2. The software is licensed under the BSD License. Here's how Michael Kneebone describes the project:

The LAF Widget (Look and Feel) project enables Swing components to be augmented with additional features or behaviour to make them more useful. Each new behaviour is contained in a "widget" which adds some specific behaviour to one (or several) types of Swing component. For instance one type of widget augments JInternalFrames by adding a thumbnail preview of the content when the mouse is hovered over a minimised frame, while another widget adds a padlock icon to uneditable text fields. Some widgets are more involved like the password strength checker widget which provides visual feedback to the user on password fields indicating the quality of the chosen password.

The key motivation behind LAFWidget is that the application writer should not have to program support for any of this behaviour him/herself.

The currently available widgets include:

  • Auto-completion (model-based / free-text) on editable combo boxes.
  • Hover preview of minimized internal frames on desktop icons.
  • Menu search panel on menu bars.
  • Hover preview of tab in tabbed panes.
  • Overview dialog on tabbed panes with optional periodic refresh.
  • Tab paging on tabbed panes.
  • Password strength checker on password fields.
  • Lock border on non-editable text components and model-based editable combo boxes.
  • Select all text in text component on focus gain.
  • Context menu on text components with edit actions (copy / paste / cut / delete / select all).
  • Enhanced drag-and-drop support for trees.
  • Scroll pane selector.
  • Selecting / deselecting in text components on Escape key press.

In his guest post, Michael talks about the disadvantages of using sub-classes to provide alternate component behavior, a strategy that less experienced Java developers are apt to choose:

Sub-classing is a very heavy handed approach for modifying GUI components due its inflexibility. Consider adding a common context menu to text components (e.g. cut, copy, paste, etc.); you could create MyJTextField, MyJTextArea, etc. subclasses adding the required behaviour. You would then be required to revisit the entire application substituting the original Swing components for these modified versions - not an attractive prospect.

Implementing the Laf-widget components is much more straightforward:

GUI development is conducted in the same way as before and all widgets automatically work with the GUI, with no added effort from the developer.

This is possible because Swing provides for pluggable Look-And-Feel, which separates the appearance and behavior of components from their actual use.

Michael describes how simple it is to include the Laf-widget project tools within your own application:

  1. Download version 4.2 or above of the LAFWidget from https://laf-widget.dev.java.net/
  2. Include the laf-widget.jar on your classpath.
  3. In the main method of your application add org.jvnet.lafwidget.LAFAdapter.startWidget(); before the GUI is created.

Once you've done that, all Swing components will appear with the Laf-widget components enabled.

To see how all this works, see the "How The Process Works" section in Michael's guest post.


In Java Today, Bruce Hopkins recently investigated Creating Interactive TV Applications With the Tru2way Platform and OCAP: 'If you're reading about the Tru2way platform for the first time, you might be asking yourself the question, "Is it really possible to have a Java-enabled TV?" Or, better yet, "Is it possible to put a JVM machine inside my cable set-top box?" The answer to both questions is yes, and you don't have to wait 5 or 10 years for this technology to come to fruition because it's already available today...'

Charles Lamb announces Berkeley DB Java Edition 3.3.82 Available: "Berkeley DB Java Edition 3.3.82 is a patch release consisting of fixes for a number of significant issues. We strongly recommend that users of the 3.3.x version upgrade to this release. There are several issues that are critical for applications using deferred write (aka temporary databases), XA, the shared environment cache, a single transaction in multiple threads, or large sets of duplicates. These critical fixes are..."

And Ajay Bhargov discusses Java Persistance with Spring, Hibernate and Maven: "In this article, I will be showing how to persist an Entity class in Java using Spring, Hibernate and Maven. Basic knowledge of Maven, Spring and Hibernate is required to go through this article. Setting up the pom.xml file..."


In today's Weblogs, Kohsuke Kawaguchi announces his new Hudson Selenium Grid Plugin: "I've released the Hudson Selenium Grid plugin, which instantly lets you deploy Selenium Grid on top of your existing Hudson cluster. By using this plugin, you can start using Selenium Grid without installing it on individual machines in the cluster manually..."

John Ferguson Smart looks forward to Making Agile Real: the Agile2009 conference: "The official Agile2009 is out, and it looks fantastic! The Agile2009 conference, in Chicago, August 24 to 28, is chock-a-block with interesting and useful sessions with a swathe of Agile rock stars. I was involved with organizing the Tools..."

And Arun Gupta summarizes the GlassFish Portfolio at JavaOne 2009 - 20 Technical Sessions, 16 Birds-of-Feather, 7 Hands-on-Labs, and much more: "Here is the list of Technical Sessions, Birds-of-Feather sessions, and Hands-on Labs delivered by the GlassFish Portfolio team at JavaOne 2009. Technical Sessions TS-3790 Java Servlet 3.0: Using Async Features in the Real World Jan Luehe, Rajiv Mordani, Gregg Wilkins TS-4012 Pragmatic Identity 2.0: Simple,..."


In the Forums, Shai Almog continues a conversation Re: menu is slower than it used to be: "Hi, that still doesn't quite help us pinpoint the problem and my same response applies regarding finding a specific revision number where a regression has/hasn't occurred. Having said that to improve your performance and possibly detect the curlpit try the following: 1. Remove the background image of the menu. 2. Disable animations in the form and background threads. 3. Make the menu opaque and make sure it doesn't feature a rounded border. 4. Use system fonts. Enable each of these iteratively to determine the main contributor for your performance issue..."

uckelman has a question about setting the maximum heap size automatically: "I'm working on a program which, as one of its functions, displays some (potentially very large) images contained in a ZIP archive. The amount of heap space used by other objects is almost always insignificant in comparison with the amount of heap space used by these images, and the actual heap requirements can vary wildly depending on the particular images the user is loading. The architecture of the program is such that one part of it (the "manager") launches child JVM instances for doing the work. This makes it possible for us to set the maximum heap size independently for each child. Presently, the max heap size is set in a preferences dialog..."

And darkman2040 has a problem with the Kerberos example Netbeans 6.7 missing security thread: "Hi everyone, I've been trying to implement the Kerberos Example and I seem to be stuck. I've configured the web service and client using Netbeans 6.7(beta). If I follow all the steps and a few odd things occur: 1. The keystore is still specifed in my policy tag. If I remove the Keystore tag then the web service deploys and I can hit it on my Tomcat server (6.0 bundled with Netbeans) when I run test web service. 2. The generated client sends a message request..."


As stated above, this week's Spotlight is Kirill Grouchnikov's Interview with Laf-Widget Project's Michael Kneebone: 'Today I am thrilled to have Michael Kneebone as a guest spot blogger on "Pushing Pixels". Michael has extended the widgetising support in the Laf-Widget project and has graciously agreed to write about its usage and how it works on the inside...'


The new java.net Poll asks: "How closely will you follow JavaOne 2009?" Voting is open through this Thursday.


In our Feature Article,


-->

The latest Java Mobility Podcast is Java Mobility Podcast 78: JSR 290 XML User Interface Markup Language, in which JSR 290 developers Natalia Medvedenko and Petr Panteleyev talk about JSR 290 and the new power it will give Java ME developers.

The latest OpenJDK Podcast is

The latest JavaOne Community Corner Podcast is


-->


Current and upcoming Java
Events
:

Registered users can submit event listings for the href="http://www.java.net/events">java.net Events Page using our href="http://today.java.net/cs/user/create/e">events submission form.
All submissions go through an editorial review before being posted to the
site.


Archives and Subscriptions: This blog is delivered weekdays as
the Java
Today RSS feed
. Also, once this page is no longer featured as the
front page of java.net it will be
archived along with other past issues in the href="http://today.java.net/today/archive/">java.net Archive.

This week's java.net Spotlight highlights Michael Kneebone's appearance as guest blogger on Kirill Grouchnikov's Pushing Pixels site...