Sha256: d3dec7b59782f0a7271b4d1b51be07fd7b57d0912eca727be9035cae965a47c0
Contents?: true
Size: 1.11 KB
Versions: 2
Compression:
Stored size: 1.11 KB
Contents
require 'java' module SensibleSwing include_package 'javax.swing' [JButton, JFrame, JLabel, JPanel, JOptionPane, JFileChooser, JComboBox, JDialog] # grab these constants (http://jira.codehaus.org/browse/JRUBY-5107) include_package 'java.awt' [FlowLayout, Font] include_class 'java.awt.event.ActionListener' JFile = java.io.File class JButton def initialize *args super *args set_font Font.new("Tahoma", Font::PLAIN, 11) end def on_clicked &block raise unless block add_action_listener do |e| block.call end self end end class JFrame def close dispose # sigh end end class JFileChooser # returns nil on failure... def go success = show_open_dialog nil unless success == Java::javax::swing::JFileChooser::APPROVE_OPTION puts "did not choose one" java.lang.System.exit 1 end get_selected_file.get_absolute_path end end end # code examples # JOptionPane.showInputDialog(nil, "not implemented yet", "not implemented yet", JOptionPane::ERROR_MESSAGE)
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
sensible-cinema-0.13.1 | bin/swing_helpers.rb |
sensible-cinema-0.13.0 | bin/swing_helpers.rb |