More action with Struts 2
In a recent review of Struts 2 in Action, JW Blogger Oleg Mikheev notes that Struts 2 is "just a collection of extensions built upon WebWork, which is ultimately the right thing to learn before starting a Struts 2 project." While Struts 2 has some architectural flaws, Oleg calls WebWork well-designed, well-tested, and reliable. What are your experiences using Struts 2 and WebWork?

Also see "Hello World the WebWork way," a JavaWorld excerpt from WebWork in Action, by Patrick Lightbody and Jason Carreira.

Newsletter sign-up

Sign up for our technology specific newsletters.

Enterprise Java
View all newsletters

Email Address:

Get ready to Swing (1.0)

The Java look and feel goes Organic -- and it adds a new default, cross-platform look

As you probably already know, the JavaSoft Swing 1.0 component group is set to appear late this month (February 1998). The Swing components are an extension to the Lightweight UI (user interface) Framework, which itself became a part of the Java AWT (Abstract Windowing Toolkit) when JDK 1.1 was introduced. One of the most important features of the Swing component set, which will be fully incorporated with Java 1.2, is its pluggable look-and-feel (L&F) architecture. This feature allows developers to choose from several preset L&Fs, or craft their own custom appearance and behavior for controls.

A look back at the pre-release Swing

The pre-release Swing, announced at the 1997 JavaOne conference and available to developers since July 1997, contains three pre-defined L&Fs:

  • Java (the original cross-platform L&F)
  • Motif
  • Windows 32-style


In the 1.0 release, the Java L&F will be renamed the Organic L&F and will include two color schemes, Santa Fe and Vancouver, not available with the pre-release Java L&F. Users of pre-release version who continue to use this L&F will have to substitute OrganicLookAndFeel for JLFLookAndFeel in code statements.

The Organic L&F, Santa Fe style

The Organic L&F, Vancouver style



The Motif L&F

The Win32-style L&F



Feedback from users of the pre-release versions of Swing (and specifically on the Java L&F) provided the design team with many ways to enhance the Java L&F for Swing 1.0. Following are some of the changes made to the Organic (neé Java) L&F.

  • Color schemes -- The Swing engineers added earth-tone Santa Fe and gray-tone Vancouver Java-looking color schemes to the Organic L&F to satisfy beta users' requests. The L&F encapsulates color information about the current UI into a Theme object, that the application can apply by using the setCurrentTheme() method. Expect Theme objects to encapsulate more than color schemes in future versions of Swing.

  • Tabbed panes -- Also from feedback, Swing engineers changed the appearance of tabs in tabbed-pane windows to better resemble folder or notebook tabs. The tabs no longer shuffle around when you select one (most developers liked it this way). Also, the justified full-width-of-window tab bug has been corrected.

  • Combo boxes -- Even though they retained most of the look of combo boxes, the engineers did make slight design modifications enabling the addition of visual clues so developers will know at a glance whether a combo box can be edited or not.

  • Scroll bars and other enhancements -- Because developers are decidely split on the rollover effect of scroll bars, no scroll bar changes have been implemented at this time. radioButtonMenuItems and checkBoxMenuItems have been enhanced. And sliders now come in filled and unfilled versions.


The Motif and Windows 32-style L&Fs are pretty straightforward. There is a locking method on the Windows L&F that keeps it from working on non-Windows platforms -- Microsoft hasn't granted JavaSoft the rights that would allow Sun to offer the Windows L&F for other platforms.

Swing 1.0 gets a new look (actually, two!)

JavaSoft is planning two additional L&Fs for Swing 1.0. The Symantec Visual Café development team and Apple engineers helped JavaSoft design the Macintosh L&F. And the JavaSoft design team has crafted a new default, cross-platform L&F (known as the Metal L&F).

The Macintosh L&F

The Metal (default) L&F



Metal was created as a compromise between the burden of overamped 3D design and the need for some sort of 3D effect to provide visual cues. Many users complained about the "bumpiness" of 3D bevels, especially on buttons in toolbars. So the designers went for an "etched" or "flush" 3D look, eliminating some of the visual clutter while still providing visual clues as to the state of the element.

The traditional, 3D bevel look (top) versus the new Metal L&F "etched" look

Also, since Metal is the new default L&F in Swing 1.0, it was designed with a simpler color model than the pre-release default, so it won't develop color-mapping problems from platform to platform. (For more on the Metal design, see "Metal design highlights" in Resources.)

According to JavaSoft officials, the Macintosh L&F won't be available when Swing 1.0 makes its debut later this month, but it should follow soon after. Also, because Metal is the new default cross-platform L&F, the Organic L&F (Vancouver and Santa Fe) will be available for downloading, but won't be bundled in Swing 1.0.

Swing's place in the JFC

Swing components support the JavaBeans event model, which means they can work "out of the box" in applications and IDEs that support beans. In JDK 1.1 (and forward), Swing is one of the five APIs that make up the Java Foundation Classes (JFC). The others are:

  • The Abstract Windowing Toolkit (AWT) -- A GUI-development toolset that serves as a foundation for many Swing classes.

  • Java 2D -- A set of classes for advanced 2D graphics and imaging; the API is based on technology from IBM/Taligent.

  • The Accessibility API -- An assistive technologies interface, designed to help people with disabilities interact with JFC and AWT components through such features as screen magnifiers and audio text readers.

  • Drag and Drop -- Based on the JavaBeans "Glasgow" specification, this technology allows data to be shared between Java and native applications, between different Java applications, and within a single Java application.


Swing component classes

Swing is implemented by three elements of the JFC:

  • UI classes -- A set of components that descended from JComponent (which descended from AWT's Container class). The hierarchy lets Swing components contain other components, which allows developers to nest components.

  • Non-UI classes (1) -- Swing-related support classes that don't create visible onscreen Swing components, but provide services to the Swing API.

  • Non-UI classes (2) -- A set of Swing-related interfaces that are implemented by Swing's component classes and support classes.


The UI classes are responsible for the pluggable L&F, component extensibility, keyboard-stroke trapping, component border customization, tool tip support (short descriptions of components), auto-scrolling, and debugging and localization support.

Resources
  • What is Swing? http://java.sun.com/products/jfc/swingdoc-current/intro.html
  • The Swing toolset http://java.sun.com/products/jfc/swingdoc-current/tool_set.html
  • The Swing Connection online newsletter http://java.sun.com/products/jfc/swingdoc-current/
  • Metal design highlights http://java.sun.com/products/jfc/swingdoc-current/chris_ryan/metal.html
  • Regular JavaWorld columnist, Todd Sundsted, demonstrates the power of Swing's lightweight components in "Put your user interface on a diet" (JavaWorld, March 1997) http://www.javaworld.com/javaworld/jw-03-1998/jw-03-howto.html