Skip to content

Instantly share code, notes, and snippets.

@taka2
Created August 21, 2008 11:54
Show Gist options
  • Save taka2/6543 to your computer and use it in GitHub Desktop.
Save taka2/6543 to your computer and use it in GitHub Desktop.
module Rubeus::Extensions::Javax::Swing
module Timer
def self.included(base)
base.extend ClassMethods
base.instance_eval do
alias :new_without_rubeus :new
alias :new :new_with_rubeus
end
end
module ClassMethods
def new_with_rubeus(interval, &block)
# Create ActionListener implement class
mod = Module.new do
define_method("actionPerformed", &block)
end
obj = Object.new
obj.extend(mod)
# Use original constructor
new_without_rubeus(interval, obj)
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment