tags:

views:

1241

answers:

5

Have you ever attempted using Swing only to end up changing courses because it just couldn't do what you wanted?

I'm pretty new to Swing, having only used it for school projects over 5 years ago, but it seems Swing has come a long way in providing a more native look and feel, so much so that I'm considering using it to develop the GUI for an app on Mac OS X. Before I do, though, I wanted to see if anyone has run into any showstopper issues that prevented them from using Swing.

Just off the top of my head, some possibilities:

  • Problems developing custom components that looked "right"
  • Bad interactions with native applications and widgets
  • Performance issues (unresponsiveness, repaint problems)
  • Inability to mimic native behaviors (like Dock interaction)
A: 

Swing is a nice way to go, or you can go SWT, or BOTH!

But either way, use them on top of the RCP platform. (either with Eclipse or Netbeans).

Have a look at this: http://www.adam-bien.com/roller/abien/entry/eclipse_rcp_vs_netbeans_rcp

marco

marcolopes
+1  A: 

Swing isn't going to give you perfect fidelity with the hosting OS. Sun simply can't devote the considerable resources necessary to do so. My impression is that Swing has gotten much better, but is still going to look out of place by default.

The minimum required to even hope to pass as a Mac app:

  • package your .jar in a .app
  • set the L&F to system default
  • set apple.laf.useScreenMenuBar property to true
    • must do this before any UI code

Dock interaction is non-existent in standard Java. You'll have to use Apple's Cocoa-Java bridge, which is no longer supported. I have no idea how tractable JNI is on OS X, which is the only real alternative.

Performance shouldn't be a problem. Drag & Drop is probably as hairy on OS X as it is everywhere else.

Basically, if you're explicitly targeting OS X you're best off using Objective-C. Its far from impossible to build an app on OS X using Java & Swing, but its a lot of work to make it look "native".

Kevin Montrose
Thanks for the ideas. My original impetus for trying Java on the Mac was to be able to gain some real experience using Clojure, which seems like an interesting language. I've decided to use Objective-C for this GUI, and maybe tackle Clojure on something non-graphical.
alanlcode
+3  A: 

@Kevin++

Using Cocoa is probably better

  • If you want it to look exactly like native applications
  • If you are targeting only the Mac

If you intend to distribute your applications for Windows, Linux, etc. Swing is a decent choice. It's better but like in any toolkit there are still issues. You'll never get a truly native look and feel with it, same goes for similar UI toolkits which claim to be "cross-platform".

The Apple Guidelines for Java development can be found here.

+2  A: 

As Kevin and John said you should try Objective-C, Cocoa and XCode if you are only targeting Mac users. The developer tools for Mac is freely available.

If you want to (or have to) use Java and Swing you can use some libraries to create a GUI that looks well on Macs:

For deploying your application you should read the JarBundler docs.

However, in this case interaction with dock and native applications is very limited.

Some other good links are:

Csaba_H
A: 

Macify can help.

Jay Askren