Developing graphical user interfaces (GUIs) used to be a tricky part of Java technology programming. Although Java Foundation Classes/Swing (JFC/Swing) technology has been around for quite a while, designing professional-looking, cross-platform GUIs can be tedious and prone to error. All this has changed with NetBeans IDE 5.0 and Project Matisse. Project Matisse solves the core problem of GUI creation by making the layout design of visual forms much easier. The project extends the NetBeans IDE 4.1 Form Editor to support a free design paradigm that exposes simple layout rules that are easy to understand and to use quickly. NetBeans IDE software engineer Roman Strobl interviews Project Matisse creators Scott Violet and Tomas Pavek.
Violet: I'm the architect for Swing and have been working on portions of the project that will make their way back into the Java Development Kit (JDK). I've been involved with Matisse almost since the beginning. Origins and Goals of Project Matisse
Pavek: The NetBeans GUI builder contains a
I realized developers were actually requesting to design the
layout in general. They wanted the GUI builder to abstract from
At the same time, we demo'd the NetBeans GUI builder at an internal workshop on GUIs, and we heard similar opinions. The GUI builder is nice, but why do you have to deal with all those paddings, insets, fills, weights, and other parameters? Couldn't we have something higher-level, more visual, and, of course, easier to use? We took the opportunity to meet with the engineers from the Swing team. They were also disappointed with the state of tools support for visual layout design. Simply put, we agreed that the problem was not in the layout managers but in overexposing them. Layout managers are good for constructing the user interface (UI) for the resulting implementation but not as the presentation principle to be used in an interactive visual tool. This fit well into my old idea of a natural layout. The way to do this was not to find another layout manager and create a new tool for it, but instead to determine what developers needed from a GUI layout design tool. That is, how could the visual tool be used to manipulate components, set up component relationships, align them, set resizability, and so on? All this had to be visual, easy, and intuitive. It also needed to be comparable to existing Apple or Microsoft tools. There had to be no need for the developer to want to take a look under the hood and see how the layout was constructed. Of course, a layout manager is necessary for the layout to work properly, but it wasn't what we needed to start with. The most important thing was the user model. After we had finished our first prototype, everyone we showed it to was amazed. We began to believe our approach was right. Creating a New Layout Manager
At some point, we'd also like to pull Pavek: As Scott already mentioned, you won't notice the
layout manager at all when working with Matisse. However, this
layout manager is quite handy for manual coding as well and can be
used separately from Matisse. From the We originally did not aim for a new layout manager or other
extensions. But we also did not want to limit the tool capabilities
significantly just because of a lack of features in the current JDK.
At the minimum, we needed the baseline support and the preferred
spacing. We also needed a layout manager that could use these new
features and also cope with the layout structure from Matisse.
Pavek: We were not keen on having an additional library, but
hopefully this is not such a big problem. Using external libraries
is quite common today: You can hardly base any bigger project on
standard JDK classes only. This library is quite small, open source,
and you get it with NetBeans automatically. As Scott said, this is
just a temporary solution until I'd also like to stress that Matisse is not replacing the previous NetBeans GUI builder -- it extends it. And it is still possible to develop forms the same way as before, by using the standard layout managers.
Matisse addresses all of these issues. Any form designed in Matisse will adapt to changes in differing component sizes that result from localization, different look and feels, or operating systems. Pavek: The main difference is that with Matisse you get a fully
cross-platform layout definition. This means that positions and
sizes of components are not defined in absolute numbers at the
moment you put them on the design canvas but computed dynamically
when running in the target environment. Matisse creates a layout
model to remember the relations between components, and
Of Two-Way Editing and Guarded Blocks
The guarded code actually does not prevent you from doing anything. NetBeans provides hooks so that you can alter the generated code and insert your own. Moreover, you can freely add additional modifications anywhere out of the guarded block -- that is, in the class constructor. You may initially feel less comfortable with this approach, but I think it eventually becomes a very natural habit. Nevertheless, two-way editing is really popular and requested, so we can't just ignore it. I can't say now whether we'll do full two- way editing or not. But definitely we would like to address the primary use case we don't cover, which is importing the UI from existing code. This is one of the features we are receiving many requests for. Violet: This is a hotly debated topic, but I think code generation is the wrong way to go. Having code generation encourages developers to tinker with it. Additionally, generating code encourages developers to end up with big gnarly classes that have layout, component creation, event wiring, and functionality. In the long term, I would like to see builders start using beans persistence or some other format for persistence. That way, developers won't feel the need to tinker with the code, and hopefully it will also result in more readable UI-related classes. Pavek: I agree. This has just not happened yet because of the lack of a suitable and standard persistence format. I'm afraid the bean persistence seems not to be capable enough at this moment. Historically, the Swing UI is also best expressed through code: Everyone learns it this way and wants to see the code if anything goes wrong. That's also why two-way editing tools are so popular. If only Swing had included declarative persistence from the beginning! But this is really a topic for a separate debate. The Strengths and Challenges of Project Matisse
Violet: The strength of Matisse is that it allows
developers who are new to Java technology to generate a form that
will honor visual guidelines of the look and feel, align components
along their baseline, and resize appropriately with any look and
feel, locale, and operating-system combination. And they can do all
of this without knowing the details of the
In the interaction part, we had to fight with the ambiguity of the user gestures. There is often more than one way to arrange the underlying model when the user drops a component. But we can't read the user's mind. The tool can do something differently than the user expected, but it should always be in a way that the user can understand, without the user feeling that something strange and complicated is happening behind the scenes -- which in fact it does. Another challenging area was the layout structure visualization -- that is, showing components' relations, alignment, resizing, and so on. The tool needs to be easy to use, so we can't present the internal structure completely in all details. But some level of information is necessary in order to see what the layout will do and why. Cross-platform layout is not a trivial thing, after all. Violet: Far and away the most challenging aspect has been how
user gestures map to the resulting layout manager. By that, I mean
what should happen to the The Road Ahead
Pavek: Just to supplement Scott's list:
And there are tons of ideas for various usability and other improvements. These are basically the ideas we have. I don't know yet how they will fit into concrete plans and concrete releases. For More Information
Project Matisse About the Author
Roman Strobl, a software engineer working on the NetBeans IDE, is based in Prague. His blog is regularly highlighted on blogs.sun.com and technorati.com. |
| ||||||||||||||||
Oracle is reviewing the Sun product roadmap and will provide guidance to customers in accordance with Oracle's standard product communication policies. Any resulting features and timing of release of such features as determined by Oracle's review of roadmaps, are at the sole discretion of Oracle. All product roadmap information, whether communicated by Sun Microsystems or by Oracle, does not represent a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. It is intended for information purposes only, and may not be incorporated into any contract.
|
| ||||||||||||