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".

2 comments:

Albertas Agejevas said...

Tsk tsk tsk, from Python on Linux to Java on Mac.

BM said...

LOL! :-) Well, I use both of them very well, each on their places. But you are right: people changing, challenging something new. Linux or Mac — both are excellent operating systems, each for its purpose.

Besides, I find Java and Linux more useful with low-power devices, like gumstix for example...