13.07.2015 Views

Java™ Application Development on Linux - Dator

Java™ Application Development on Linux - Dator

Java™ Application Development on Linux - Dator

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

378Chapter 17Other Ways: Alternatives to Swing17.2THE IBM SWT TOOLKITThe Standard Widget Toolkit is a complete GUI library for Java, completelyindependent of Swing and AWT. It is implemented as a library of nativemethods, so it cannot be ported to any Java runtime unless that platform hasthe native part of the SWT library implemented for it.17.2.1 Another GUI Toolkit. Why?The first questi<strong>on</strong> <strong>on</strong>e should ask, perhaps, is why create an alternative GUI?Good questi<strong>on</strong>. The answer, according to the SWT FAQ, 3 primarily has to dowith executi<strong>on</strong> speed and look-and-feel similarity to native GUI applicati<strong>on</strong>s<strong>on</strong> each platform.If we may editorialize, we find neither reas<strong>on</strong> particularly compelling, althoughthe executi<strong>on</strong> speed argument made some sense when the Eclipseproject started. Swing is unlikely to win any performance awards, even thougheach versi<strong>on</strong> brings some improvements in speed. 4 Still, these reas<strong>on</strong>s do notseem particularly compelling for such a large duplicati<strong>on</strong> of effort and functi<strong>on</strong>ality.Whatever the reas<strong>on</strong>, SWT exists. SWT works by providing a thin abstracti<strong>on</strong>layer over native GUI features. It is a small GUI library. It is implementedusing the Java Native Interface, so it requires that a native binary library beimplemented for your platform. Fortunately, such implementati<strong>on</strong>s exist forall platforms Eclipse runs <strong>on</strong>. So if you can run Eclipse, you can write and runSWT applicati<strong>on</strong>s.3. http://dev.eclipse.org/viewcvs/index.cgi/~checkout~/platform-swt-home/faq.html4. The questi<strong>on</strong> of speed in Java is a rather tired argument. If maximum speed is a primaryc<strong>on</strong>cern, Java is probably not your first choice of a development language. In our experience,speed is something everybody says they need, but more often than not other c<strong>on</strong>siderati<strong>on</strong>ssuch as development time and error rate are much more important. Java is fast enough for virtuallyall MIS applicati<strong>on</strong>s, and that is the market Java is squarely aimed at. Our computerskeep getting faster, disk drives and memory keep getting cheaper. The “resource” and “performance”arguments <strong>on</strong>ly apply to applicati<strong>on</strong>s where experienced designers would already havechosen C or assembly language. Besides, with the JIT compilers in both Sun’s and IBM’s JDKs,a well-written Java applicati<strong>on</strong> is often as fast or faster than some other compiled languages, atleast <strong>on</strong> the sec<strong>on</strong>d run of the code.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!