Class: RSwing::Components::Button

Inherits:
JButton
  • Object
show all
Includes:
Component, Events::ButtonEvents
Defined in:
lib/rswing/components/button.rb

Overview

Button-Class. Wraps JButton-Class.

Constant Summary

Constants included from Events::ButtonEvents

Events::ButtonEvents::ActionListener, Events::ButtonEvents::ChangeListener, Events::ButtonEvents::ItemListener

Constants included from Events::FocusEvents

Events::FocusEvents::FocusListener

Constants included from Events::PropertyChanged

Events::PropertyChanged::PropertyChangeListener

Constants included from Events::InputMethodEvents

Events::InputMethodEvents::InputMethodListener

Constants included from Events::HierarchyBoundsEvents

Events::HierarchyBoundsEvents::HierarchyBoundsListener

Constants included from Events::KeyEvents

Events::KeyEvents::KeyListener

Constants included from Events::MouseWheelEvents

Events::MouseWheelEvents::MouseWheelListener

Constants included from Events::MouseMotionEvents

Events::MouseMotionEvents::MouseMotionListener

Constants included from Events::MouseEvents

Events::MouseEvents::MouseListener

Constants included from Events::ComponentEvents

Events::ComponentEvents::ComponentListener

Instance Method Summary collapse

Methods included from Events::FocusEvents

event_mappings

Methods included from Events::InputMethodEvents

event_mappings

Methods included from Events::HierarchyBoundsEvents

event_mappings

Methods included from Events::KeyEvents

event_mappings

Methods included from Events::MouseMotionEvents

event_mappings

Methods included from Events::MouseEvents

event_mappings

Methods included from Events::ComponentEvents

event_mappings

Constructor Details

#initialize(text, options = {}, &block) ⇒ Button

  • text: The Text to be displayed on the button.

  • options: Options-Hash with the following valid values:

  1. :visible => true

  2. :enabled => true

  3. :belongs_to => nil # Container to which this button should be added (default: none)

  4. :layout => nil # Layout-Options (e.g. GridBagContraints-Object) (default: none)

  5. :icon => nil # Icon-Symbol to be displayed next to/instead of the text on the button (default: none)

  6. :name => :okButton Name of the buttons for access via parent-container (default: none)



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/rswing/components/button.rb', line 37

def initialize(text, options = {}, &block)
  super(text)
  
  self.visible = Options.value_for(options => :visible)
  self.enabled = Options.value_for(options => :enabled)
  self.icon = Options.value_for(options => :icon)

  # call block with current object, if given
  if block_given?
    yield self
  end
  
  unless options.empty?
    Container.add_if_requested(self, options)
  end
end