Class: MainWindow
Instance Method Summary collapse
-
#initialize ⇒ MainWindow
constructor
A new instance of MainWindow.
- #show_blocking_message_dialog(message, title = message.split("\n")[0], style = JOptionPane::INFORMATION_MESSAGE) ⇒ Object
Constructor Details
#initialize ⇒ MainWindow
Returns a new instance of MainWindow.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/count_down_timer_jruby_swing.rb', line 17 def initialize super "countdown" set_size 150,100 setDefaultCloseOperation JFrame::EXIT_ON_CLOSE # happiness @jlabel = JLabel.new 'Welcome to Sensible Cinema!' happy = Font.new("Tahoma", Font::PLAIN, 11) @jlabel.setFont(happy) @jlabel.set_bounds(44,44,160,14) panel = JPanel.new @panel = panel @buttons = [] panel.set_layout nil add panel # why can't I just slap these down? panel.add @jlabel @start_time = Time.now @jlabel.set_text 'welcome...' starting_seconds_requested = (ARGV[0] || '25').to_f*60 @switch_image_timer = javax.swing.Timer.new(1000, nil) # nil means it has no default person to call when the action has occurred... @switch_image_timer.add_action_listener do |e| seconds_left = starting_seconds_requested - (Time.now - @start_time) if seconds_left < 0 setVisible(true) toFront() "timer done!" @start_time = Time.now else # avoid weird re-draw issues @jlabel.set_text "%02d:%02d" % [seconds_left/60, seconds_left % 60] end end @switch_image_timer.start self.always_on_top=true end |
Instance Method Details
#show_blocking_message_dialog(message, title = message.split("\n")[0], style = JOptionPane::INFORMATION_MESSAGE) ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/count_down_timer_jruby_swing.rb', line 9 def (, title = .split("\n")[0], style= JOptionPane::INFORMATION_MESSAGE) # I think I'm already on top... setVisible(true); toFront() JOptionPane.showMessageDialog(nil, , title, style) true end |