Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Beautifying a SWT application on Mac

Tags:

java

macos

swt

SWT is designed to be cross-platform, so it can run on a Mac. The problem is it commits the cardinal sin of Macland - it's UGLY. Toolbars don't look like Mac toolbars, status bars don't look like Mac status bars, etc.

Does anyone have any experience in making an SWT application look more like a Mac application? For example, by making platform-specific JNI calls via the 'OS' class in SWT? If so, how difficult was it?

(This question arises because we are looking at porting an existing SWT app designed to run on Windows)

Thanks

like image 578
Mark Avatar asked Nov 20 '09 10:11

Mark


3 Answers

This is usually problem of Swing not SWT (SWT is directly linked to OS/framework provided widgets) - a quote from A gentle introduction to SWT and JFace 2:

SWT is a library that creates a Java view of the native host operating system GUI controls. It is host implementation-dependent. This means SWT-based applications have several key characteristics: 1. They look, act, and perform like "native" applications. 2. The widgets provided reflect the widgets (the components and controls) provided on the host operating system. 3. Any special behavior of the host GUI libraries is reflected in SWT GUIs.

The pre 3.5 Milestone used to use Carbon framework and now the 3.5+ supports both 32/64bit Cocoa framework 1 so perhaps that has caused you confusion? Or can you be more specific, give us the version you use and some screenshots / sample code to reproduce?

I have been developing java application based on SWT/Eclipse RCP for a while on OSX and have not found and major problem with look&feel (of cause it does not 100% comply the Apple HID 3 as it complies with Eclipse UIG)

like image 79
fikovnik Avatar answered Nov 11 '22 08:11

fikovnik


The best I can offer is to use either MacWidgets or Quaqua which are both free and in different stages of maturity. The bad news would be that they are both Swing based which is probably not what you want to hear.

like image 42
willcodejavaforfood Avatar answered Nov 11 '22 09:11

willcodejavaforfood


You can make your application look and behave like mac application easily. Apple supplies a application called JarBundler with it you can put your menu items up where they belong it will also build a double click able executable, and you can set a icon.

Swing components on Mac OS X looks a lot like their cocoa components, and for OS X you can set some special flags that will make them just like their cocoa counter parts, such as you can set a flag for a JTextField and make it look like cocoa search field.

Also all Macs come with java pre-installed so thats one less worry.

like image 20
Hamza Yerlikaya Avatar answered Nov 11 '22 08:11

Hamza Yerlikaya