Skip to content

Instantly share code, notes, and snippets.

@rdp
Last active August 29, 2015 14:00
Show Gist options
  • Save rdp/11152096 to your computer and use it in GitHub Desktop.
Save rdp/11152096 to your computer and use it in GitHub Desktop.
require 'jruby'
require 'pp'
JFrame = javax.swing.JFrame
JCheckBox = javax.swing.JCheckBox
JOptionPane = javax.swing.JOptionPane
class JCheckBox
def on_clicked &block
add_item_listener { |e|
block.call isSelected
}
end
end
module SimpleGuiCreator
def self.go
# javax.swing.SwingUtilities.invokeLater{
temp_frame = JFrame.new
temp_frame.show
begin
JOptionPane.showMessageDialog(temp_frame, "message", "title", JOptionPane::INFORMATION_MESSAGE)
ensure
temp_frame.dispose
end
#}
end
end
class Go
def self.go
frame = JFrame.new
checkbox = javax.swing.JCheckBox.new
frame.add(checkbox)
checkbox.on_clicked { |new_value|
puts "after_checked #{new_value}"
pp caller(0)
SimpleGuiCreator.go
}
frame.setSize(200,200)
frame.show
puts "done showing"
end
end
Go.go
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment