Class: javaxjavax::swing::JFrame::CloseListener

Inherits:
Object
  • Object
show all
Defined in:
lib/simple_gui_creator/jframe_helper_methods.rb

Overview

class StateListener

include java.awt.event.WindowListener

end

Instance Method Summary collapse

Constructor Details

#initialize(parent, &block) ⇒ CloseListener

Returns a new instance of CloseListener.



16
17
18
19
20
# File 'lib/simple_gui_creator/jframe_helper_methods.rb', line 16

def initialize parent, &block
  super()
  @parent = parent
  @block = block
end

Instance Method Details

#windowClosed(event) ⇒ Object

sometimes this, sometimes the other…



22
23
24
25
26
27
28
# File 'lib/simple_gui_creator/jframe_helper_methods.rb', line 22

def windowClosed event # sometimes this, sometimes the other...
  if @block
   b = @block # force avoid calling it twice, since swing does seem to call this method twice, bizarrely
@block = nil
b.call
  end
end

#windowClosing(event) ⇒ Object



30
31
32
33
# File 'lib/simple_gui_creator/jframe_helper_methods.rb', line 30

def windowClosing event
   #p 'windowClosing' # hitting the X goes *only* here, and twice? ok this is messed up
@parent.dispose
end