Download Using JRuby - Parent Directory

Transcript
Chapter 10
Building GUIs with Swing
You’ve heard it before: “write once, run anywhere,” or WORA for short.
The term has been used (and overused) by Java developers over the
past decade and a half to refer to the Holy Grail of portability. Reality
never quite lives up to the hype, and indeed WORA’s early waves of
promise crashed against the familiar rocks of platform-specific quirks.
The story is more hopeful today, especially in the area of GUI development. If you write a Java GUI application on Windows, it can also
run on Mac OS, Linux, or any other platform where Java runs—while
taking on a native look and feel.
However, for Java language developers, this comeback has been hardearned. Swing, the primary GUI API for Java, is a byzantine framework.
It works great once you’ve invested your blood and sweat into making a robust application. But the amount of effort needed to learn the
ins and outs of Swing often frustrates developers into abandoning the
framework altogether.
10.1 JRuby to the Rescue!
There has been an explosion of GUI frameworks for JRuby. Most of
these work by papering over some of Swing’s more puzzling complexities. They also reduce the amount of boilerplate code you have to write,
by leaning on powerful Ruby features like blocks.
Prepared exclusively for Shohei Tanaka