Currently, J2S’ SWT widgets are on the way of being pixel-precise. And some certain pain things come up:
1. Different browsers
IE (IE6/5.5/5.0 and IE7, too many, I mainly work on IE6), Firefox (Different versions will render position in some slight differences), and Opera (Just check out to see if there are ugly looks in Opera 8+, no pixel-precise supports)
2. Native SWT implementation v.s. browser implementation
I have to debug into the native SWT implementation, and look for the native positions of different widgets, and then debug into the JavaScript’s SWT implementation to see if the positions match. And thanks a little, the JavaScript is actually the Java codes, so I can do refactors or navigate between codes easily by Eclipse. And J2S’ inner console also helps a lot for printing out those necessary values. The procedures is something like developing C codes for Java to call through JNI.
3. CSS layout v.s. JavaScript layout
The SWT implementation requires both CSS layout and JavaScript layout. CSS is powerful, but it’s also too complicated and it has its pitfalls on dynamical layout and it can not tell complicate rules. JavaScript’s layout is free to anything but requires extra CPU times on calculating positions. And the position is mixed up with all kinds of CSS styles, for example, different “font-size”s, different “border”s, different “margin”s, …
4. What about supporting different CSS templates
…en, big thing, until almost 90%+ SWT APIs are implemented. …
Actually J2S’ SWT will hide the above pains from SWT developers.
SWT developers or web application developers only need to develop the native SWT applications and then enable Java2Script compiler for the Eclipse project. Then the compiler will convert Java things into JavaScript. After packing the generated resources (image and css and javascript) up with the J2S SWT libraries. You will get your web applications. You won’t have the above pains, as those pains belong to J2S SWT team.
Here following is a testcase snapshot.
Native Win32 SWT window:
Converted J2S SWT window in IE6: