Tuning Java Swing apps for Mac OS X
tarkin writes "Sven Van Caekenberghe just finished a tutorial article, 'Tuning Java Swing applications for Mac OS X', that explains how to tune standard Java Swing applications to conform to the Mac OS X User Experience and make them virtually indistinguishable from native Mac OS X applications. Topics include handling basic Apple events, packaging applications, adding a custom icon, file dialogs, about boxes, preferences, customizing the menu bar, supporting Finder drag-and-drop, standard help, and basic multi-document support, as well as using MRJToolkit and MRJAppBuilder. The PDF of the article, as well as a Mac OS X disk image with a binary version of the two demo applications and the source code can downloaded from his home page."
Yeah. Sure.
You don't know what you're talking about.
Applications can be slow. The OS is not slow.
Java on OSX is rather speedy, and compares favorably with the previous platform I've used it on, Linux.
Cocoa apps are totally speedy, as fast as C apps.
Carbon apps that are poorly made will be slow, and if they're really poor (like IE) they can slow the whole system down.
But your generalizations are just wrong.
Yeah, and you guys panned the ipod too: http://apple.slashdot.org/article.pl?sid=01/10/23
I thought that is what you got with Java on the mac.
I've been doing mostly server side stuff so I can't say for sure, but it is my understanding that you write a Swing UI Java App on the Mac and on the Mac you get the Aqua look and feel. This is from conversations with an Apple developer who was the person who wrote it, but I may have misunderstood.
At the very least it should be one of the choices for looks that you get with swing (Remember windows, metalic, etc?)
So you write a swing app and on OS X it looks like OS X and on Windows it looks like Windows and on Linux it looks like Windows and on Solaris it looks like Swing.
You're right about apple optimizing their JVM etc. The reason 1.4 is delayed (so the rumors go) is that they are doing a complete rewrite. From what I saw with 1.3 they've done some great improvements on what Sun ships.
Wouldn't realbasic do what you want as well? One language-- though it has C support as well-- and deploy on at least Windows and Mac with the same UI.
Inherently when you make a multi-platform dynamically-chosen-look and feel, or consistent look and feel across all platforms, there WILL be compromises because the platforms are different.
So, I'm not sure what you're looking for-- if you think that someone can make one that dynamically picks the right UI without any compromises (java's slowness, or ui variations) then I think you're not quite understanding the problem correctly.
Personally, I have no desire to support the windows platform anymore, so I just do everything in Cocoa with Objective-C. And objective-c rocks. I thought Java was the paragon of perfect languages, but I have to admit I like objective-c better.
Yeah, and you guys panned the ipod too: http://apple.slashdot.org/article.pl?sid=01/10/23
One reason for using the Aqua L&F, though, is that it is better optimized for OS X. Try running a complex application in Metal on OS X and again in Aqua. In my experiance the difference was quite aparent. You have a point though that the feel of java apps on OS X is still not quite right, but using Metal isn't any better (it just makes things more ugly).
Cocoa apps have the same file path problem. NSDocument based apps now use FSRef's as well as NSURL's so they don't, but if you write a Cocoa app that doesn't use NSDocument, its up to you to do the FSRef magic you need to track files based on their HFS+ id number.
Can I Play With Madness?
The advantage of using a non-Aqua theme for Swing apps is you don't get confused. You see a Metal app you expect Swing behavior, then you see an Aqua app you expect Aqua behavior.
Your assessment of Cocoa apps is correct except I would add that FSRefs also work on UFS volumes (and probably others) with the one caveat that you can't pass an FSRef to another process.
What Apple ought to do is what they did with the Toolbox more then a dacade ago which is to say deprecate functions (methods) which use file paths as arguments. Instead they ought to use something equivalent to an NSFSRef as a simple file primitive. They should also revise the Aqua HI Guidelines to clarify the behavior of "Save" and "Revert" to reflect the proper Mac behavior which can currently be had by using NSDocuments or FSRefs. They should also clarify that a file's path is variable, not constant.
Ironically Swing apps behave more like Cocoa apps in at least one aspect: the behavior of text views. NSLayoutManager doesn't behave correctly. For example selecting down on the right side will select the trailing linefeed of the last line selected which doesn't follow the Mac convention.
Unfortunately these problems are NOT going to be fixed unless more people send Apple feedback and bug reports.
>80 column hard wrapped e-mail is not a sign of intelligent
>life