Skip to content

Instantly share code, notes, and snippets.

@supermomonga
Last active August 29, 2015 14:20
Show Gist options
  • Save supermomonga/50b8c78064af82ea631c to your computer and use it in GitHub Desktop.
Save supermomonga/50b8c78064af82ea631c to your computer and use it in GitHub Desktop.
JRubyFXでコンストラクタに引数を渡しつつControllerを切り替える ref: http://qiita.com/supermomonga/items/20464ed426c7e4bdb7a4
class ApplicationController
include JRubyFX::Controller
def move klass, *args
@stage.fxml klass, initialize: args
@stage.show
end
end
class BarController < ApplicationController
def initialize arg
puts "I got `#{arg}` as a constructor argument!"
end
def click_button
move FooController, "Hello, Foo!"
end
end
class FooController < ApplicationController
def initialize arg
puts "I got `#{arg}` as a constructor argument!"
end
def click_button
move BarController, "Hello, Bar!"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment