Skip to main content

Matisse: one step closer to cross platform layout nirvana

Posted by zixle on June 10, 2005 at 11:07 AM PDT

Yow, it's been more than a month since my last blog! I intended to
write a blog once a week, but, well, finishing up table sorting, JavaOne and Matisse have kept me unbelievably busy in the past month:( I'll blog later about table sorting and other Mustang goodness. In the mean time I wanted to blog about Matisse. Matisse shows work that the NetBeans and Swing teams have been deeply involved in for close to a year (YOW!) now. For those interested there is a long thread on javalobby talking about Matisse. In this blog I'll cover some of the new JDK features that make Matisse possible.

Baseline support

In visual designers paradise all components are aligned nicely along
their baseline. For example, labels should be aligned along their
baseline with textfields. To date this has been problematic because
we haven't provided an API for getting this information, meaning lots
of tricks and assumptions. Thankfully we've added this API and it's
now part of Mustang. For details read an older blog on

baseline layout
. Matisse makes extensive use of
this API to allow aligning components along their baselines. For
details on the API see

Preferred Gap

Each of the platforms

, Gnome

) provides guidelines as to how far apart various widgets should be placed from each other. We wanted the ability to make it easy for developers to honor these guidelines. You can see this in the Matisse demo, as the components gets close enough they snap to a location based on the guidelines of the current look and feel. The API is in the works for mustang and was discussed in a thread
on the swing forums.


So how does all this tie together? Yes, a new LayoutManager called
GroupLayout. The LayoutManager offers the ability to align components along their baseline as well as to easily place components using the preferred gap API. GroupLayout itself is, in some ways, a combination of BoxLayout and SpringLayout. It's more constrained than SpringLayout and we are investigating moving it on top of
SpringLayout. Later on I'll provide more details of GroupLayout. For those coming to JavaOne we'll cover it the layout roundup talk.

Do we really need to wait for Mustang to use this?

No! We realize it's important for developers to use this on pre 1.6,
even pre 1.5 JREs. As such, we've rolled these three pieces into an
open source project that runs on 1.4.2, and newer, JREs. The project
is under the swing-labs umbrella and is called swing-layout. For more information, including source, head over to its home page.

Related Topics >>