Module: FileChooser
Overview
used in the cli only…
Instance Method Summary collapse
Instance Method Details
#choose_file(title, use_this_dir = nil) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/file_chooser.rb', line 22 def choose_file(title, use_this_dir = nil) fc = java.awt.FileDialog.new(nil, title) if use_this_dir # FileDialog only accepts it a certain way. dir = File.(use_this_dir).gsub(File::Separator, File::ALT_SEPARATOR) fc.setDirectory(dir) end # lodo allow for a FileFilter, too... Thread.new { sleep 2; fc.to_front } # it gets hidden, unfortunately, so try and bring it again to the front... fc.show if fc.get_file out = fc.get_directory + fc.get_file end fc.remove_notify # allow out app to exit out end |