Created
July 27, 2011 13:56
-
-
Save coffeeaddict/1109406 to your computer and use it in GitHub Desktop.
include_package
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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