Getting Started with the Print API

The next newly official API in 6.5 is the Print API. It works in the same way as the new 'feature' that lets you specify the size of the popped-out TopComponent: via a client property (which implies that there should be the same ui for it, i.e., a checkbox in the Window Component wizard):

 

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.

Comments:

Very nice. But I think NB Platform would have a lot more uptake if it wasn't so NB-specific...I think if you rewrote it to run on top of an OSGi container using regular OSGi plugins and extension points a lot more people would be open to it.

Like it or not but OSGi is the defacto standard for module/plugin development on the Java platform.

Posted by Jacek on November 20, 2008 at 03:05 AM PST #

Jacek, you'd be surprised to find how many people within Sun agree with you. Look at GlassFish, for example. And here's something that should interest you:
http://wiki.netbeans.org/OSGiAndNetBeans

Posted by Geertjan on November 20, 2008 at 03:11 AM PST #

Post a Comment:
  • HTML Syntax: NOT allowed
About

Geertjan Wielenga (@geertjanw) is a Principal Product Manager in the Oracle Developer Tools group living & working in Amsterdam. He is a Java technology enthusiast, evangelist, trainer, speaker, and writer. He blogs here daily.

The focus of this blog is mostly on NetBeans (a development tool primarily for Java programmers), with an occasional reference to NetBeans, and sometimes diverging to topics relating to NetBeans. And then there are days when NetBeans is mentioned, just for a change.

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
12
13
14
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today