Class: SimpleGuiCreator::JButton
- Inherits:
-
Object
- Object
- SimpleGuiCreator::JButton
- Defined in:
- lib/simple_gui_creator/swing_helpers.rb
Instance Method Summary collapse
- #disable ⇒ Object
- #enable ⇒ Object
-
#initialize(*args) ⇒ JButton
constructor
A new instance of JButton.
- #on_clicked(&block) ⇒ Object
- #simulate_click ⇒ Object
- #tool_tip=(text) ⇒ Object
Constructor Details
#initialize(*args) ⇒ JButton
Returns a new instance of JButton.
52 53 54 55 |
# File 'lib/simple_gui_creator/swing_helpers.rb', line 52 def initialize(*args) super(*args) set_font Font.new("Tahoma", Font::PLAIN, 11) end |
Instance Method Details
#disable ⇒ Object
99 100 101 |
# File 'lib/simple_gui_creator/swing_helpers.rb', line 99 def disable set_enabled false end |
#enable ⇒ Object
95 96 97 |
# File 'lib/simple_gui_creator/swing_helpers.rb', line 95 def enable set_enabled true end |
#on_clicked(&block) ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/simple_gui_creator/swing_helpers.rb', line 57 def on_clicked &block raise unless block # sanity check @block = block add_action_listener do |e| begin block.call rescue Exception => e # e.backtrace[0] == "/Users/rogerdpack/sensible-cinema/lib/gui/create.rb:149:in `setup_create_buttons'" bt_out = "" for line in e.backtrace[0..1] backtrace_pieces = line.split(':') backtrace_pieces.shift if OS.doze? && backtrace_pieces[1..1] == ':' # ignore drive letter colon split, which isn't always there oddly enough [1.8 mode I guess] filename = backtrace_pieces[0].split('/')[-1] line_number = backtrace_pieces[1] bt_out += " #{filename}:#{line_number}" end puts 'button cancelled somehow!' + e.to_s + ' ' + get_text[0..50] + bt_out if $simple_creator_show_console_prompts if $VERBOSE puts "got fatal exception thrown in button [aborted] #{e} #{e.class} #{e.backtrace[0]}" if $simple_creator_show_console_prompts puts e.backtrace, e if $simple_creator_show_console_prompts end end end self end |
#simulate_click ⇒ Object
83 84 85 |
# File 'lib/simple_gui_creator/swing_helpers.rb', line 83 def simulate_click @block.call end |
#tool_tip=(text) ⇒ Object
87 88 89 90 91 92 93 |
# File 'lib/simple_gui_creator/swing_helpers.rb', line 87 def tool_tip= text if text text = "<html>" + text + "</html>" text = text.gsub("\n", "<br/>") end self.set_tool_tip_text text end |