JRuby with Swing

30分プログラム、その74。JRubyで遊ぼう。

require 'java'
include_class 'javax.swing.JFrame'
include_class 'javax.swing.JLabel'

frame = JFrame.new('hello')
frame.add JLabel.new('Hello,world!!')
frame.setSize 200,100
frame.setVisible true
loop{}
  • RubyGUIを使いたいときは、Swingというのもひとつの手だな
  • 継続は使えない
  • Ruby->Javaはできるけど、逆はできない(当然)