lib/swing_helpers.rb in sensible-cinema-0.15.0 vs lib/swing_helpers.rb in sensible-cinema-0.16.1
- old
+ new
@@ -3,12 +3,13 @@
include_package 'javax.swing'
[JProgressBar, JButton, JFrame, JLabel, JPanel, JOptionPane,
JFileChooser, JComboBox, JDialog, SwingUtilities] # grab these constants (http://jira.codehaus.org/browse/JRUBY-5107)
include_package 'java.awt'
[FlowLayout, Font]
- include_class 'java.awt.event.ActionListener'
+ include_class java.awt.event.ActionListener
JFile = java.io.File
+ include_class java.awt.FileDialog
class JButton
def initialize *args
super *args
set_font Font.new("Tahoma", Font::PLAIN, 11)
@@ -36,9 +37,26 @@
success = show_open_dialog nil
unless success == Java::javax::swing::JFileChooser::APPROVE_OPTION
java.lang.System.exit 1 # kills background proc...but we shouldn't let them do stuff while a background proc is running, anyway
end
get_selected_file.get_absolute_path
+ end
+
+ # match FileDialog
+ def set_title x
+ set_dialog_title x
+ end
+
+ def set_file f
+ set_selected_file JFile.new(f)
+ end
+ alias setFile set_file
+ end
+
+ class FileDialog
+ def go
+ show
+ File.expand_path(get_directory + '/' + get_file) if get_file
end
end
class ModeLessDialog < JDialog
def initialize title_and_display_text, close_button_text= 'Close'
\ No newline at end of file