public
Created

JRuby gives me the opportunity to find which is worse, my Swing or my Ruby

  • Download Gist
app.jruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
require 'java'
swing_classes = %w(JFrame JButton JList JSplitPane
JTabbedPane JTextPane JScrollPane JEditorPane
DefaultListModel ListSelectionModel BoxLayout
JScrollPane JTree tree.TreeModel
text.html.HTMLEditorKit tree.DefaultMutableTreeNode tree.TreeNode)
swing_classes.each do |c|
java_import "javax.swing.#{c}"
end
 
 
def main
n = 0
frame = JFrame.new("Disk File Info")
dir = Dir.new("./testdir")
dir_node = DefaultMutableTreeNode.new(dir)
tree = JTree.new(dir_node)
scrollPane = JScrollPane.new(tree)
dir.each { |f|
node = DefaultMutableTreeNode.new(f)
dir_node.insert(node, n)
n += 1
}
cp = frame.getContentPane()
cp.add(scrollPane)
 
frame.setDefaultCloseOperation(JFrame::EXIT_ON_CLOSE)
frame.pack()
frame.set_visible(true)
end
 
main

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.