Wednesday, February 20, 2008

Java Swing UI and MacOS X

I wrote an application using Swing UI library, but it does not fits to MacOS X by default. So here is a small tip how to bring main menu to MacOS. So, in your Java Swing application, if you need this:



...to be done like this:


...set com.apple.macos.useScreenMenuBar to true. It is possible to do as JVM parameter (-D is your friend), but better within the application somewhere at the beginning in the main() as follows:

System.setProperty("com.apple.macos.useScreenMenuBar","true");

This is one more step toward Apple MacOSX integreation. However, this is good for Java 1.3 and less. These days we use 1.5 or 1.6 developers preview. :-) It is quite sad that Apple Java releases takes a gap for about a year, but on the other hand Java on Mac really that stable and reliable. Well, anyway, here is the list of deprecated values system properties that were available in Java 1.3.1 but are likely trying to be no longer supported since Java 1.4.1. This is not very true due to they are supported in Java 1.6, though it is nice to get rid of them ASAP:

1. "com.apple.macos.use-file-dialog-packages" and "com.apple.macos.useScreenMenuBar" are replaced with "apple.laf.useScreenMenuBar".

2. "com.apple.macos.useSmallTabs" and "com.apple.macosx.AntiAliasedTextOn" are replaced with "apple.awt.textantialiasing".

3. "com.apple.mrj.application.growbox.intrudes" replaced with "apple.awt.showGrowBox".

Sunday, February 17, 2008

Bye-bye ReportLab

Recently I am having fun playing with my new toy: porting my Python project "OpenRML" to Java. Python's OpenRML is using ReportLab library as a PDF generator. Among it is relatively slow, also there are number of features I really missing. Also it is quite expensive by time to add third-party stuff. So I've decided to say "bye-bye" to ReportLab.
First thought was to re-implement stuff in Jython or Groovy, because these are dynamic languages. But then I've decided to go with plain Java to avoid troubles in a future.
In this project, will no more ReportLab's RML markup for documents for a number of reasons. In short: I want markup to be small, cute, flexible and extendable, unlike RML. I had implemented a reporting middle-ware in Aozora Bank and now I see why RML is quite clunky idea.
Now, the project is in very early stage, no any RPC server yet and data integration. But it already can produce something: rich text paragraphs, coloring, fancy tables, clickable table of contents, insert images from URL or file etc. 
Today I had implemented Japanese QRCode barcode. It is amazing data encoding, which is damage-resistant and can contain lots of data on quite small print-out size. We have plenty of them everywhere and we need them on a paper too. I also working on mobile application, which scans the code from a camera or any image and decodes it back to text.

Screenshot below shows what my current newly ported from Python library produces:



Tomorrow I am going to implement SVG support. :-)