Class: ButtonApp
- Inherits:
-
Object
- Object
- ButtonApp
- Defined in:
- lib/jrubyconf-button.rb
Constant Summary collapse
- LABELS =
["Drink Me", "Eat Me"]
Instance Attribute Summary collapse
-
#shell ⇒ Object
readonly
Returns the value of attribute shell.
Instance Method Summary collapse
- #close ⇒ Object
-
#initialize ⇒ ButtonApp
constructor
A new instance of ButtonApp.
Constructor Details
#initialize ⇒ ButtonApp
Returns a new instance of ButtonApp.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/jrubyconf-button.rb', line 11 def initialize display = Swt::Widgets::Display.get_current @shell = Swt::Widgets::Shell.new @shell.setLayout(Swt::Layout::FillLayout.new) = Swt::Widgets::Button.new(@shell, Swt::SWT::PUSH) .set_text(LABELS[0]) .add_selection_listener do new_text = LABELS[(LABELS.index(.text) - 1).abs] .text = new_text end @shell.pack @shell.open end |
Instance Attribute Details
#shell ⇒ Object (readonly)
Returns the value of attribute shell.
7 8 9 |
# File 'lib/jrubyconf-button.rb', line 7 def shell @shell end |
Instance Method Details
#close ⇒ Object
27 28 29 |
# File 'lib/jrubyconf-button.rb', line 27 def close @shell.dispose end |