开发者

Which one to use: Java Swing or GTK+ for GNOME desktop application?

开发者 https://www.devze.com 2023-02-06 07:54 出处:网络
I am considering developing a GNOME desktop application with a graphical user interface. I know GTK+ is the first choice, especially when developing for the GNOME environment. End users also consider

I am considering developing a GNOME desktop application with a graphical user interface. I know GTK+ is the first choice, especially when developing for the GNOME environment. End users also consider GTK+ as the first choice for applications they use. I am, however, considering future improvements: what if my application will need a port to another environments or 开发者_如何学COS like KDE or Mac or Windows? Which is the best way to go: Java Swing (because it's platform independent) or GTK+?


Use GTK+. It's available for Windows as well if you ever do want to port it, and integrates infinitely much better with gnome.


UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
SwingUtilities.updateComponentTreeUI( this );

On *nix variants, that should produce the GTK PLAF in Swing. On Apple(1) it will probably produce a theme with 'Aqua' in the name, and on Windows(1) it will be something like 'Windows'.

1) I doubt that Windows or Apple users want to see a 'GTK look' app. on their desk-top. ;)


My users generally prefer Swing, but GTK applications are only slightly more difficult to maintain cross-platform.

GTK doesn't run natively on Mac OS X;

GTK and its dependencies can be built using MacPorts, and popular open source tools such as Gimp and Inkscape include the required libraries in the application bundle.

it requires to install an X server.

X11 for Mac is "fully integrated with Mac OS X."

Addendum: As @ptomato notes, the portfile offers both Quartz and X11 variants.


The answer depends on what you actually want.

GTK library is native in the Gnome environment: if you want to develop an application thought for Gnome, use GTK.

If you are not so much interested in giving a native feel to the Gnome users then use whatever you want (GTK, Swing, Qt, wx ...).


By the way if you want my personal opinion, I prefer GTK a lot. I personally don't like Swing, especially when it tries to emulate GTK look and feel.

0

精彩评论

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