# Cheri: Builder-style JRuby/Swing GUI development

**URL:** <https://www.ruby-forum.com/t/cheri-builder-style-jruby-swing-gui-development/118649>\
**Category:** Ruby\
**Created:** [October 29, 2007, 8:09pm UTC](https://www.ruby-forum.com/t/cheri-builder-style-jruby-swing-gui-development/118649 "2007-10-29T20:09:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![headius](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/7c8e57/32.png) [@headius](https://www.ruby-forum.com/u/headius)\
**Post date:** [October 29, 2007, 8:09pm UTC](https://www.ruby-forum.com/t/cheri-builder-style-jruby-swing-gui-development/118649/1 "2007-10-29T20:09:05Z")

</div>

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 ([http://cheri.rubyforge.org/](http://cheri.rubyforge.org/))

“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

---

<div class="post-metadata">

**Author:** ![headius](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/7c8e57/32.png) [@headius](https://www.ruby-forum.com/u/headius)\
**Post date:** [October 29, 2007, 8:55pm UTC](https://www.ruby-forum.com/t/cheri-builder-style-jruby-swing-gui-development/118649/2 "2007-10-29T20:55:16Z")

</div>

On 10/29/07, Charles Oliver N. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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

---

<div class="post-metadata">

**Author:** ![headius](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/7c8e57/32.png) [@headius](https://www.ruby-forum.com/u/headius)\
**Post date:** [October 29, 2007, 11:15pm UTC](https://www.ruby-forum.com/t/cheri-builder-style-jruby-swing-gui-development/118649/3 "2007-10-29T23:15:42Z")

</div>

Robert D. wrote:

> On 10/29/07, Charles Oliver N. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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 🙂

- Charlie
