Skip to content

Instantly share code, notes, and snippets.

@coffeeaddict
Created July 27, 2011 13:56
Show Gist options
  • Save coffeeaddict/1109406 to your computer and use it in GitHub Desktop.
Save coffeeaddict/1109406 to your computer and use it in GitHub Desktop.
include_package
module Foo
require 'java'
include Java
include_package 'javax.swing'
class MyView < JFrame
def initialize
super "Casper"
self.initUI
end
def initUI
panel = JPanel.new(BorderLayout.new)
self.getContentPane.add panel
end
end
end
# fails with NameError: uninitialized constant Foo::MyView::JPanel
module Foo
require 'java'
include Java
include_package 'javax.swing'
class MyView < JFrame
include_package 'javax.swing'
def initialize
super "Casper"
self.initUI
end
def initUI
panel = JPanel.new(BorderLayout.new)
self.getContentPane.add panel
end
end
end
# works
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment