Download NetBeans!

20060419 Wednesday April 19, 2006

Music NotePad (Part 4)

I was up until 4.00 this morning, migrating the syntax highlighting from my initial implementation to the new drag-and-drop JFugue interface. Before doing that, I migrated the "Save" functionality. Now you can save the music string in the Editor to a Midi file (all I had to do was add three lines of code that work with the JFugue API). Below, you see the "Save" menu item selected:

As you can see, I am using the Napkin Look & Feel by Alex Lam and Ken Arnold (as promised in the comments at the end of yesterday's blog entry). Isn't it cool? Takes some getting used to (and reminds me of Quinton Blake's illustrations in Roald Dahl books). It took me a long time to get Alex's NBM modules installed in this application. For some reason, they just wouldn't "kick in". I thought it might be because of a problem in the application itself, so I tried it in NetBeans IDE 5.0 instead. Same problem. I reached Alex's update center, downloaded the modules, but nothing changed after restarting the IDE. Then I connected to Alex's update center again and was able to download the modules again. This can only mean that they didn't install in the first place (if they had already been installed, I wouldn't have been able to install them a second time). So, then I saved a copy of the modules that I was supposedly downloading (there's a very handy "Copy" button in the Update Center wizard that allows you to do that). Then I tried to manually install the modules, from my local hard disk where I had saved the modules. Still nothing happened. Finally, I unpacked the modules (after all, NBM files are just glorified ZIP files) and put the contents in the correct places in my user directory. First I tried this in NetBeans IDE and it worked. Then I tried it in my own application. And there it worked too. (This means, I think, that Alex's Napkin modules work for NetBeans IDE 5.5, since that's the IDE, or at least a dev build of that IDE, that I'm building my application on.) So, for me, on Windows XP, there's some problem with installing Alex's modules. However, in the process of going through all this I learnt quite a lot (I discovered the "Copy" button and I worked out where in the user directory to put the contents of an NBM file in order for the module to be installed when the application starts).

During my experimenting, I also tried out other look-and-feels for the first time. Here are the two most common ones, at least, these two are mentioned in the NetBeans documentation (although the Motif look and feel didn't give me much joy because I didn't see my buttons at all). By the way, the first one below is pretty cool, I found it in an e-mail on nbusers.

# Metal look and feel:
# default_options="--laf javax.swing.plaf.metal.MetalLookAndFeel 
#--fontsize 14 
#-J-Dswing.aatext=true 
#-J-Dswing.metalTheme=steel 
#-J-Dswing.plaf.metal.controlFont=Dialog-plain-14"

# Motif look and feel:
# default_options="--laf com.sun.java.swing.plaf.motif.MotifLookAndFeel 
#--fontsize 14"

One small thing about the Napkin look and feel—wouldn't it be cool if this look and feel also affected the titlebar? To me, the titlebar looks too normal (i.e., boring) in the context of this really fun and zany look and feel. (The other thing is, the dropped notes don't look so great in this look and feel, but that's probably because the buttons are so tiny. On the other hand, the notes now look pretty cool because they don't seem to be on top of buttons at all. But it is a pity that you see that little square around them, which is of course the button.)

One final point—yesterday I mentioned how building on top of the NetBeans Platform allows you to leverage some of the underlying infrastructure provided by NetBeans. In yesterday's blog entry I looked at the great topcomponent functionality ("Minimize" and drag-and-drop of topcomponents) that you get for free (i.e., without any programming on your part). Well, if you look at the screenshot above, you'll notice that I've added a "Tools" menu. In fact, I didn't add it—the point is that I didn't remove it. That Tools menu comes straight from the NetBeans Platform and contains the Library Manager, the Palette Manager, the Options window, the Module Manager, and the Update Center wizard. If you're wondering why, just think about the case of the Update Center wizard: what if I distribute my application in a ZIP file (i.e., not as a webstartable application, which would be equally possible). What happens when I have updates to this application? For example, JFugue is going to come out soon with functionality that allows you to open Midi files and change them. So, say that I have already distributed my application. All I'd need to do is create a module that provides enhanced features for the updated JFugue API, and then I would distribute that together with a module that contains the updated JFugue API itself. And then you would be able to use the Update Center wizard, because I included (or, kept) that functionality in the Music NotePad. Now, is that cool, or what? I didn't need to create the Update Center wizard, because some NetBeans engineers that I'll never know about did all the work for me; but to you, the innocent user of my application, it looks as if I did the work. Yay me.

Apr 19 2006, 03:38:28 AM PDT Permalink

Trackback URL: http://blogs.sun.com/geertjan/entry/music_notepad_part_4
Comments:

Hmmm, the installation problem is certainly annoying. (I think I get one response from the mailing list with similar issues)

Although I'm using NB6 daily, I am actually building the module using the NB5 Platform downloaded from netbeans.org (The link says "NetBeans Platform 5.0 download")
Is it normal for it to say "NetBeans Platform Dev (Build 200601251500)" in the Platform Manager though?

As for the button, I wonder if you could do a setBorder(EmptyBorder) - or are you suggesting Napkin to do that by default with small image buttons?

I have been learning about how to get rid of the title bars - it seems possible with Swing (Metal seems to do it nicely) - so stay tuned ;-)

Posted by Alex Lam on April 19, 2006 at 04:46 AM PDT #

Now if only people start to build these applications on the NetBeans Platform - we will start to have NetBeans plugins (modules) that will serve more general functionalities than just the IDE.

From there onwards things would (and should) get rather interesting.... :-)

(Can't wait to compose music with your application, btw :-P)

Posted by Alex Lam on April 19, 2006 at 04:57 AM PDT #

Hey Alex, firstly, I didn't know about setBorder(EmptyBorder). I just tried it, even with fully qualified class name:

setBorder(javax.swing.border.EmptyBorder)

But it seems that even though the class is in code completion, I get a red error square in NetBeans, telling me that the whole "border" subpackage isn't found. Do you have any idea what I should do? Secodnly, about your question, I think that is normal, to have the build number displayed in the Platform Manager (I think it is helpful). About the title bars -- I would like to use the Music NotePad in some upcoming demonstrations and, while doing so, I'd like to use the Napkin look-and-feel as my default look-and-feel. However, the one thing that might make me change my mind is the fact that the titlebar isn't included in the look and feel. That gives it an incomplete look. I know I'm being picky, but I hope you'll prioritize including the titlebar, because for the rest it looks great. (By the way, in the IDE, I saw some strange effects: when I selected a node in the Projects window, or other explorer windows, I guess, the text in the node became invisible.) Finally, I like the last point that you make, about general functionalities for NetBeans Platform apps. However, do you have any examples in mind? For example, if I were to provide a spellchecker module, there would need to be some generic interface that all modules make available, for them to work with my spellchecker module. So what I'm saying is, wouldn't generic functionalities in modules imply that there'd have to be some interface with existing functionality in applications that want to use it? Or you're probably thinking about functionality that doesn't interact with any of the application's current functionality. Maybe a weather forecasting service, for example, that connects to a JAX-WS web service and provides an application with updates and changes to the forecast. That would be interesting. Thanks for the thoughts and sorry for the long response. Thanks for the great and creative look and feel.

Posted by Geertjan on April 19, 2006 at 05:26 AM PDT #

By the way, here's the metal look-and-feel (using the exact settings that I mentioned above in my blog entry). Here there doesn't seem to be any effect on the titlebar either. Or maybe there's an additional flag I should set?

<img src="http://blogs.sun.com/roller/resources/geertjan/metal1.png">

Posted by Geertjan on April 19, 2006 at 05:35 AM PDT #

Oh, I'm so sorry that I have caused confusion - that was my shorthand, not working Java code! (curse me if you want, I promise I won't do it again!)

The java code should read yourButton.setBorder(new EmptyBorder(0, 0, 0, 0)) - and of course you can set some padding spaces around instead of zeros ;-)

The "invisible" text is the Platform failing to let me say the colours of things inside these components - so it becomes white on white, if you see the point ^^"

For general purpose NetBeans modules, take Napkin Look & Feel and your application as an example; ideally only the end user of your application is involved in scribbling their Music Notepad on a piece of Napkin, i.e. download the module from the Update Center then restart the application. Another example that exists is the GMail checker module - a musician might want an out-of-box experience, right? ;-)

I have been struggling about whether to implement the custom ComponentUIs that NetBeans has for its UI - it doesn't sound worth-while if it only works for the IDE alone. However, if now any applications on the NetBeans platform can utilise Napkin, then the whole story is different!

About the title bar - it is my personal priority as of now, so after finishing my write-up on QEC (Quantum Error Correction) and my revision before exam I'll get it straight out and done right after those tasks.

(I'll get back to you once I recover the information about Metal, it's gotta be somewhere...)

Posted by Alex Lam on April 19, 2006 at 06:45 AM PDT #

AFAIK, you can only do it programmatically using JFrame.setDefaultLookAndFeelDecorated(true) and JDialog.setDefaultLookAndFeelDecorated(true)

So I added a check and these statements in the Napkin module, so now it will have customised title and borders for JFrame and JDialog. Get it from the UC ;-)

Screen shot of metal's JDialog borders: http://napkinlaf.sourceforge.net/netbeans/metal_dialog.PNG

(The main window itself is resistance to change - it is probably created before my module is loaded, which is odd + annoying, to say the least; rather than filing an issue report I think I'll see to it myself. Let's see if I can bring more good news :-P)

Posted by Alex Lam on April 19, 2006 at 07:25 AM PDT #

Here's some further thoughts about NB platform modules. As can be inferred from the examples earlier, modules that provides a small yet useful functionality would certainly benefit from the auto update of NetBeans.

However, as you have stated it would also be desired for developers to write modules that provides a more abstract layer of service, i.e. a library module. This is the idea which I think needs some reinforcement even for the NetBeans IDE alone.

I have seen quite some numbers of modules that depends on say jdom, but ended up packaging a seperate copy of the library within their own NBM. I can understand if 2 modules need a different version of the jdom API, but most of the time the overlap hence the waste in space and memory and performance is unnecessary.

Yet with the trend of people writing libraries and package them as NetBeans modules, the download size and hassle can be minimised - user will only have to download each required NBM library once (e.g. if everyone starts to extend functionalities upon the Gmail API, then your Music Notepad users will just have to download the API NBM once, yet download those tiny modules for the specific functionalities that they want within their application)

Last but not least, one might start to worry about getting into tangled situations like an application named "Eclipse IDE" run into - people have to hunt all over the 'net for modules. But I believe that can be resolved with existing architecture of nbextras.org, or something new but similar.

So what do you think? :-) (sorry to fill up your blog with long comments!)

Posted by Alex Lam on April 19, 2006 at 08:04 AM PDT #

Even "worse" - non-programmers can start building their own applications!

Say I am an oil field control engineer, who is also a chess-master. My company will give me that monitor program which is written on the NetBeans Platform, which I stare at (well, not literally :-P) every day. Since not much is goint to happen in between, life can get boring. But since the monitor application is on NB Platform, he can go to the Update Center and download a AI or even online Chess module, which he can use to kill spare time.

Oh and then for this project I'll need to communicate with another engineer some distance away. So I go to the Update Center, grab the Collab module with chat functionalities, and within minutes we are happy searching for oil leaks, all within NetBeans!

N.B. all the above actions do not require me to have any knowledge in Java whatsoever ;-)

So it illustrates a possibility for non-programmers to "mix & match" on top the Platform, just the things that they want or need. I would think it is difficult (for the Collab module), if not impossible (chess module), for the original program to pre-package these functionalities in the first place.

Posted by Alex Lam on April 19, 2006 at 08:20 AM PDT #

Hi Alex, firstly, please don't apologize for your long comments. I'm really thinking along the same lines as you so it is great to share thoughts. Secodnly, I've installed the modules again (again in the same circuitous way by unzipping the NBM files and manually pasting them in the right places) but I don't get anything different in the title bar (however, thanks a lot for explaining the thing about the borders of the buttons, that's really improved everything for me because now the notes look SO much better). Please look at this pic, just paste the URL in the browser, and you'll see the current situation with (a) no borders around buttons, (b) the same titlebar as before:

http://blogs.sun.com/roller/resources/geertjan/napkin3.png

Also, note that I integrated the Google toolbar into this application. Yes, I also thought about the Gmail Checker. There is a LOT that can be done in creating these kind of cool modules that would be useful for ALL apps built on the NetBeans Platform.

I really like what you're saying about non-programmers creating applications by mix and matching from the update centers. That's kind of very high-level component-based application development! Each module would be a component and the only reason for getting one would be its usefulness to the end user, and it would be the end user who would get the updates. Your chess and collab examples are exactly on the mark.

So, now, please help me with the titlebar of the application!

Posted by Geertjan on April 19, 2006 at 08:31 AM PDT #

Napkin has yet to have a customised title border yet - to see the title borders (for JDialogs) in Metal, just do the "--laf" trick as you have tried before.

I'll try harder to get my module to load even earlier (before the main JFrame, that is) and get the Napkin borders (and the NB ComponentUIs) implemented once I finish my work at hand (or I'll get kicked out of school :-/)

Nice to share opinions with you as well! ;-)

Posted by Alex Lam on April 19, 2006 at 08:48 AM PDT #

OK, cool, Alex. Sorry for misunderstanding. Nothing wrong with getting kicked out of school, you can become a fulltime NetBeans developer instead (you won't need any money because you won't have time to eat and sleep and therefore not need money for food and shelter).

Posted by Geertjan on April 19, 2006 at 10:18 AM PDT #

I wouldn't mind, in fact - as long as my spirit remains and there is computer input interfaces for spirits ;-)

Posted by Alex Lam on April 19, 2006 at 11:37 AM PDT #

Oh I have forgotten to mention - I reinstalled (updated to the latest daily) NB6 and while adding the NB5 Platform in manager, its harness is set to use the IDE's one (which is "5.0 update 2")

So out of curiosity I set it back to the release platform's one ("5.0") then try to build the NBMs - huh, the sizes are different, so something could be different.

The older harness does not allow "Create NBMs" from context menu of the Module Suite project though, so I need to copy and cut and paste stuff to make up my updates.xml ^^"

I have just tested it from the UC and it works (well, it always works for me anyway) - if you have time would you mind sparing a few minutes to test if it works for you now? :-)

Posted by Alex Lam on April 19, 2006 at 11:48 AM PDT #

Great news, Alex! I just downloaded and installed a daily dev build of 5.5 from netbeans.org. I then contacted your update center via the Update Center wizard, got your modules, and then followed instructions and had the IDE restart itself. And... there it was Napkin!!! (Onlyp roblems for me apart from titlebar issue discussed above is that disabled buttons have invisible icons and selected nodes in explorer windows have invisible text.)

Posted by Geertjan on April 20, 2006 at 09:49 AM PDT #

Post a Comment:

Name:
E-Mail:
URL:

Your Comment:

HTML Syntax: NOT allowed