By Geertjan-Oracle on Nov 19, 2008
putClientProperty("print.printable", Boolean.TRUE); // NOI18N
Just put the above in your TopComponent constructor and you're good to go. Let's say, for example, that this is what your TopComponent looks like...
Now, to provide Print functionality, all you need to do is add the above single line of code to the constructor of the above TopComponent. Then the File | Print menu item will automatically be enabled. Alternatively, instead of clicking that menu item, press Ctrl-Alt-Shift-P. (According to Tom Wheeler in an e-mail to me, in order to do this "you'd need amazing dexterity, several years of emacs experience or assistance from a passerby to press all those keys simultaneously".)
You'll then find yourself with this dialog, which you can use for printing purposes:
That's pretty cool. One step in the direction of providing business functionality out of the box. I'm looking forward to similar enablement-functionality for login, persistence, and other business/CRUD functionality, as described here in Issuezilla (which should get you here at some point). After all, as someone said at the NetBeans Demo Camp in Munich: "Why does JSR-296 have a cool business application generator in NetBeans IDE, while the NetBeans Platform doesn't?" Good question! The concept of a NetBeans Business Platform (something that Ralph Lance, at the same demo camp in Munich, asked me about... 3 years ago or so... and I was reminded of the moment I saw him again) would be great to introduce. It would be an absolutely killer approach to all the low level NetBeans Platform details.