Subscribe Favorite

A Better Way to GUI Ruby Apps

Written on August 24, 2007 by Hendy Irawan

Profligacy is a JRuby library that makes building Swing Graphical User Interface much easier than with Raw code. It’s not a builder as with many other projects, but instead a simple Ruby way to structure the UI for the 80% common cases you’ll encounter.

It’s actively used in the Utu iHate client. iHate started as a RubyCocoa project and then convert to JRuby and Swing.

The purpose of Profligacy is not to be a complete way of hiding Swing components from you. You’ll still be making JButtons and JLabels, you’ll just be putting them into a Ruby idiomatic code structure that doesn’t make your eyes hemorrhage diarrhea like when you try to code in Java.

The only real innovation in Profligacy is a simpler way to configure a GroupLayout using a simple regex/wiki style syntax. This is a work in progress, but it should make building GUIs much much easier.

Sample code:

require 'profligacy/swing'
require 'profligacy/lel'

module Test
  include_package 'javax.swing'
  include Profligacy

  layout = "
     [ label_1         | label3      ]
     [ (300,300)*text1 | (150)people ]
     [ <label2         | _           ]
     [ message         | buttons     ]
  "

  ui = Swing::LEL.new(JFrame,layout) do |c,i|
    # nothing here for now
  end

  ui.build(:args => "Simple LEL Example")
end

The result:

Profligacy

TADA! :-)
No fluff required.

Profligacy is really easy to use, but you should still be referring to the Swing™ docs to learn how to actually use the components.

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
If you enjoyed this post Subscribe to our feed

 

Trackbacks

(Trackback URL)

  • Morning Brew #67

    August 26, 2007 at 6:14 am

    [...] A Better Way to GUI Ruby Apps. [...]

close Reblog this comment
blog comments powered by Disqus