声明:JavaEye新闻文章的版权属于JavaEye网站所有,严禁任何网站转载本文,否则必将追究法律责任!
Cheri提供了用JRuby创建Swing Builder应用的框架,采用特定域语言(DSL),使得只需要非常简单的代码就创建优秀的Swing应用。
推荐下载超酷视频:(46.3 MB)总共: 17分钟15秒
http://media.screencastic.com/public/video_assets/1/01-cheri.mov
Cheri主页:http://cheri.rubyforge.org/
下面是简单的例子:
Cheri::Swing hello world
Cheri::Swing and Cheri::Html

推荐下载超酷视频:(46.3 MB)总共: 17分钟15秒
http://media.screencastic.com/public/video_assets/1/01-cheri.mov
Cheri主页:http://cheri.rubyforge.org/
下面是简单的例子:
Cheri::Swing hello world
require 'rubygems'
require 'cheri/swing'
include Cheri::Swing
f = swing.frame('Hello World') { label 'Hello!' }
f.pack
f.visible = true
Cheri::Swing and Cheri::Html
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

来自:cheri.rubyforge.org


评论 共 3 条 发表评论
rubynroll 2008-07-08 16:17 引用
ruby优雅灵活的语法对于GUI开发有非凡的意义,然而创建符合Ruby Way的GUI binding并非容易。我用过RubyGenome2,感觉非常好,不知道这个RubySwing作得如何...
zsbfree 2008-07-08 11:33 引用
xiuxiuxiu 2008-07-07 22:48 引用
不知道具体的应用环境是什么?