Sha256: 68a336bc3d11ef4b664f297581116071853c13e3e3fdcd513e873e50ac6d4cd8

Contents?: true

Size: 645 Bytes

Versions: 1

Compression:

Stored size: 645 Bytes

Contents

module FileChooser

  # show a popup dialog prompting for them to select a file
  # pretty ugly
  def choose_file(title, use_this_dir = nil)
    fc = Java::javax::swing::JFileChooser.new("JRuby panel")
    fc.set_dialog_title(title)
    fc.setCurrentDirectory(java.io.File.new(use_this_dir)) if use_this_dir
    # lodo allow for a FileFilter, too...
    success = fc.show_open_dialog(nil)
    if success == Java::javax::swing::JFileChooser::APPROVE_OPTION
      fc.get_selected_file.get_absolute_path
    else
     nil
    end
  end
  
  extend self
  
end

if __FILE__ == $0
  p FileChooser.choose_file("test1", '..')
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sensible-cinema-0.7.0 lib/file_chooser.rb