开发者

Build Java UI to run on all platforms

I am really confused over what to use. Options I see are awt, Swing and swt.

My question is which should be best for Desktop Java app on all platforms( Mac,Windows and Linux )with开发者_C百科 minimum platform dependent code ?


AWT is obsolete, though some of its classes and design form the underpinnings of the Swing API.

Here is my take on the differentiators between creating applications in Swing and SWT:

Swing

  • + Forms part of the standard Java-SE platform, so fewer distribution headaches
  • + You can create a consistent look and feel across platforms
  • + Controls are lightweight, so creating your own is relatively easy
  • - If you need Swing applications to look like native applications, there may be a lot of work in it; Swing can be styled with a platform look'n'feel, but the results aren't always close enough for everyone's satisfaction

SWT

  • + Easy to create simple applications which use native widgets
  • - Manual resource management
  • - You need to distribute platform-specific libraries
  • - You face the lowest-common-denominator problem - not all widgets are available on all platforms, so some will be custom to SWT anyway

Although I've put a lot more minuses against SWT, I wouldn't discount it. Which technology you pick will depend on your project requirements. Picking the library is only the beginning when it comes to UI development.

Swing is the easy, low-maintenance option and I'd agree with the other posters that this is probably the best fit for what you want.


Swing.

AWT is old and too low-level, SWT has native components, and doesn't ship with the JRE (it's a third-party library). Swing is high-level (-ish), and pure-java.


I would go with Swing as the best choice using what's packaged with Java. However, even Swing can make you jump through all the same hoops every time, so I would recommend looking into one of various frameworks that build on top of it and handle most of the boilerplate work of building an app.

There's a JSR for a Swing Application Framework which I have used when it was still in active development, but it's currently frozen. Their project page recommends a fork of that project, and another one called GUTS which uses Google Guice as its dependency injection. Netbeans also has Netbeans Platform.

I know the scope of these frameworks goes outside the realms of "UI", but they handle things like data-binding between your model and your UI which Swing does not do.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜