Cheri: Builder-style JRuby/Swing GUI development

Ara mentioned wanting to hear more about Swing-based GUI stuff in JRuby,
so here’s a quick intro to some of the frameworks available right now
for doing Swing stuff. I’d like to know what people think of these and
what’s missing. There’s a bunch, so I’ll do this as separate posts.

“Cheri is a framework for creating builder applications; that is,
applications that build or represent hierarchical, tree-like,
structures, using a declarative syntax. Cheri includes a number of
builders based on the framework, as well as a builder–builder for easily
creating new builders or extending existing builders. Cheri also comes
with a demo application, Cheri::JRuby::Explorer (CJX), that is built
using two of the supplied builders (Cheri::Swing and Cheri::Html).”

Cheri is very much a builder for Swing, hiding most aspects of the Swing
component behind a declarative language. So here’s a simple example:

Hello World:

@frame = swing.frame(‘Hello World’) {|obj|
size 200,150; box_layout obj, :Y_AXIS
on_window_closing { puts ‘bye!’; @frame.dispose }
y_glue
x_box { label ‘Hello!’ }
y_glue
}
@frame.visible = true

A simple HTML example:

require ‘cheri/swing’
require ‘cheri/html’
include Cheri::Swing
include Cheri::Html

folks = {
“Susan” =>“Wife”, “Larry” =>“Son”,
“Bob” => “Friend”,“MaryAnne” => “Friend”,
}
@frame = swing.frame(‘Swing and Html’) { |frm|
size 240,180; box_layout frm,:Y_AXIS
content_pane { background :WHITE }
default_close_operation :EXIT_ON_CLOSE
menu_bar {
menu(‘File’) { mnemonic :VK_F
menu_item(‘Exit’) { mnemonic :VK_X
on_click { @frame.dispose }
}}}
scroll_pane {
align :LEFT
editor_pane {
content_type ‘text/html’
editable false
background color(255,255,240)
html {head {
style “body { font-family: sans-serif; }” }
body {div(:align=>:center) {
table(:width=>‘90%’,:border=>1) {
tr th(‘Name’), th(‘Relationship’),
:bgcolor=>:yellow
folks.each do |name,rel|
tr(:bgcolor=>’#e0ffff’) {
td {name}; td {rel} }
end
}}}}}}
}
@frame.visible = true

  • Charlie

On 10/29/07, Charles Oliver N. [email protected] wrote:
I am very happy with your decision to post a lot about JRuby, I feel
this is an absolute feat for the list.

It would however put a cherry on top of the whipped cream if you
labeled your posts [JRuby], well it would be my cherry, how do others
feel about this idea?

Cheers
Robert

Robert D. wrote:

On 10/29/07, Charles Oliver N. [email protected] wrote:
I am very happy with your decision to post a lot about JRuby, I feel
this is an absolute feat for the list.

It would however put a cherry on top of the whipped cream if you
labeled your posts [JRuby], well it would be my cherry, how do others
feel about this idea?

I can certainly do that, at least when it’s a purely informational post.
But I may forget sometimes :slight_smile:

  • Charlie