SWT vs. Swing: API

April 2, 2004 at 2:23 pm Leave a comment


Today two major and incompatible UI libraries are available for Java developers: SUN’s Swing and IBM’s SWT (which is used for the Eclipse platform). Often it is claimed that SWT is the faster and more stable solution. Since in our projects Swing was fast and stable enough a point of major interest was the API: What is easier and more flexible to program. I did a little experiment based on the very good SWT tutorial “Using the Eclipse GUI outside the Eclipse Workbench, Part 1: Using JFace and SWT in stand-alone mode” from Adrian Van Emmenis. I took the SWT file explorer consisting mainly of a tree and a table from the tutorial and programmed an equivalent Swing file explorer. The code can be downloaded for the SWT-File-Explorer and the Swing-File-Explorer.
The main differences between the two explorers:

  • The Swing explorer needs with 249 LOC about 30% more lines of code than the SWT explorer with 192 LOC.
  • Setting the properties of SWT widgets is follows the C style with expressions like SWT.HORIZONTAL SWT.NULL. Since the properties are simply integers there is a (small) lack of type safety.

One (subjective) word about performance: When using the two explorers I can hardly notice any difference. Only when directories contain very many files the SWT explorer seems to be a bit faster.

Entry filed under: Uncategorized. Tags: .

JUnit vs. Fitnesse Online Pattern Catalogs

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Trackback this post  |  Subscribe to the comments via RSS Feed



%d bloggers like this: