RSwing - Swing wrapper for JRuby

RSwing is licensed under the GNU LGPL v3. For more information, take a look at the LICENSE file.

RSwing is a wrapper of the Swing GUI-Framework of the Java Platform for JRuby. The goal is to provide a ruby-ish wrapper library to Swing, which makes it feel more like an actual ruby library rather than just a plain interface to the java classes.

For example, RSwing tries to make heavy use of blocks, symbols and similar typical ruby concepts.

Some examples:

Frame.new("hello, world") do |frame|
  frame.default_close_operation = :exit_on_close
  frame.size = [200,200]

  # create a new button, belonging to this frame with a given name to access it easily later
  Button.new("OK", :belongs_to => frame, :name => :okButton) do |btn|

    btn.on_click do
      Dialog.show "Button clicked!", :dialog_type => :info, :title => "My Title", :belongs_to => frame
    end

    btn.on_focus do
      puts "button has now focus"
    end

    btn.on_focus_lost do
      puts "button has lost focus"
    end
  end

  # accessing components of frame via :name attribute given to button:
  puts "text property of okButton: #{frame[:okButton].text}"

  # options-dialog
  options = ["Yes", "No", "Cancel"]
  selected_value = Dialog.show_option(options.join(" or ") + "?",
                                      :option_values => options, 
                                      :option_type => :yes_no_cancel,
                                      :belongs_to => frame)

  puts "#{selected_value} was selected"

  frame.visible = true
end