Class: ButtonApp

Inherits:
Object
  • Object
show all
Defined in:
lib/jrubyconf-button.rb

Constant Summary collapse

LABELS =
["Drink Me", "Eat Me"]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeButtonApp

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)
  
  button = Swt::Widgets::Button.new(@shell, Swt::SWT::PUSH)
  button.set_text(LABELS[0])
  button.add_selection_listener do
    new_text = LABELS[(LABELS.index(button.text) - 1).abs]
    button.text = new_text
  end
  
  @shell.pack
  @shell.open
end

Instance Attribute Details

#shellObject (readonly)

Returns the value of attribute shell.



7
8
9
# File 'lib/jrubyconf-button.rb', line 7

def shell
  @shell
end

Instance Method Details

#closeObject



27
28
29
# File 'lib/jrubyconf-button.rb', line 27

def close
  @shell.dispose
end