Class: SensibleSwing::JButton
- Inherits:
-
Object
- Object
- SensibleSwing::JButton
- Defined in:
- lib/swing_helpers.rb
Instance Method Summary collapse
-
#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.
31 32 33 34 |
# File 'lib/swing_helpers.rb', line 31 def initialize *args super *args set_font Font.new("Tahoma", Font::PLAIN, 11) end |
Instance Method Details
#on_clicked(&block) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/swing_helpers.rb', line 36 def on_clicked &block raise unless block @block = block add_action_listener do |e| begin block.call rescue Exception => e puts 'got fatal exception thrown in button [ignoring]', e, e.class puts e.backtrace.join("\n"), e end end self end |
#simulate_click ⇒ Object
50 51 52 |
# File 'lib/swing_helpers.rb', line 50 def simulate_click @block.call end |
#tool_tip=(text) ⇒ Object
54 55 56 57 58 59 60 |
# File 'lib/swing_helpers.rb', line 54 def tool_tip= text if text text = "<html>" + text + "</html>" text = text.gsub("\n", "<br/>") end self.set_tool_tip_text text end |