X

Geertjan's Blog

  • August 24, 2006

Quickly Previewing a TopComponent... with Look-and-Feel of Choice

Geertjan Wielenga
Product Manager
The Matisse update pack, which I first referred to in yesterday's blog entry, has a very nice toy... "Preview Design", with a look and feel that you can register and select. In the Projects window, you can right-click a TopComponent (or other Swing containers, but since I'm mostly interested in TopComponents, that's what I'll focus on here) and select a look and feel:

...and then... immediately, without any programming or fuss on your part, you can see your GUI with the look and feel of your choice. Here's my TopComponent with the cool Napkin Look and Feel (or, as someone in Munich referred to it, when I demoed it there at the Siemens conference a few months ago, the "Manager's Look and Feel"):

In the first screenshot above, everything above the line, in the "Preview Design" menu, is provided by default. Everything below the line was registered by me. So, you can now register a look and feel in the IDE. After you've done so, the look and feel appears in the "Preview Design" menu. And how do you register a look and feel? Nothing simpler. Point and click, that's it. Just download the JAR from the look and feel's website, and then go to the Swing/AWT Palette Manager (under the Tools menu):

First, notice that there are now more categories, because the Matisse update pack has broken the looong list of Swing components into more manageable categories (matched in the Component Palette). By the way, this reorganization is going to help me in demonstrations—in the heat of the moment, I can never find the JLabel or the JTextField, in that enormous list. Now that enormous list is a lot less enormous, so the chances of me finding the components I need without looking like an idiot are at least larger than before.

But, anyway, apart from the reorganized Swing components, there's a new category, right at the end, called "Look and Feels". You'll also find it in the Component Palette, but you need to do something special (that I haven't yet worked out) to make the drag and drop work (I'm assuming it is possible, otherwise that category wouldn't be in the Component Palette). So, all you do is click "Add from JAR". A wizard opens, you browse for your JAR file (the one from the look and feel's website) and click Next. Then you wait a few seconds while all the classes in the JAR file are loaded. One they're loaded, you get a screen containing all the classes in the JAR file. Then you need to select the class/es called xxxLookAndFeel. For example, for Napkin, choose this one:

For Lipstik, choose this one:

Sometimes, as with JGoodies (below), you might have several choices:

(Maybe the IDE should only load classes called xxxLookAndFeel, except that, I guess, there's no law saying that a look and feel provider must call the relevant class xxxLookAndFeel.)

After that, click Next and then choose the category (i.e., this must be "Look and Feels", as far as I can tell, which implies that this step shouldn't be necessary) where you want to put the look and feel. Then... the wizard is finished, the look and feel will appear in the "Preview Design" menu, and you can preview your TopComponent as described above.

Pretty handy, if you quickly want to make sure that your u.i. is going to look okay in multiple different look and feels. Now, what would be really nice is if you could select a default look and feel and then use a keyboard shortcut to invoke the preview design... And something else: How about seeing the same TopComponent simultaneously in multiple look and feels?

In other news. Oops. I guess I forgot about the "Keyboard Shortcut of the Week"! Watch this space tomorrow (and send me an e-mail with nominations for this prestigious award).

Join the discussion

Comments ( 5 )
  • Frank Thursday, August 24, 2006
    Nice,
    but i'm running netbeans 5.5 beta 2 and i also would like to install it.
    How can i do that?
    Thanks
  • Geertjan Thursday, August 24, 2006
    The 5.0 update will not work in 5.5 builds (inc. betas). The good news is that we do plan to release Matisse Update Pack on 5.5 Beta Update Center as well. Likely in the NetBeans 5.5 RC1 (release candidate 1) time frame, currently planned for October.
  • Bruce Scheidemantel Tuesday, August 29, 2006
    Nice idea, perhaps it would be nice to have a similar preview menu for various versions using our internationalized text.
  • Geertjan Wednesday, August 30, 2006
    That's possible in the same Matisse Update Pack. I will blog about that feature soon.
  • efrain blanco fonseca Thursday, October 12, 2006
    es una gran idea lo que hacen, los felicito de todo corazon
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.