Class: RSwing::Components::ComboBox
- Includes:
- Component
- Defined in:
- lib/rswing/components/combo_box.rb
Constant Summary
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
-
#[](item_index) ⇒ Object
Returns an item at a given index.
-
#initialize(items = nil, options = {}) ⇒ ComboBox
constructor
Valid items are either an array or a ComboBoxModel object.
-
#items ⇒ Object
Returns the items of this ComboBox as an Array.
Methods included from Events::FocusEvents
Methods included from Events::InputMethodEvents
Methods included from Events::HierarchyBoundsEvents
Methods included from Events::KeyEvents
Methods included from Events::MouseMotionEvents
Methods included from Events::MouseEvents
Methods included from Events::ComponentEvents
Constructor Details
#initialize(items = nil, options = {}) ⇒ ComboBox
Valid items are either an array or a ComboBoxModel object. e.g.: ["First item", "Second item"] (default: nil)
Valid options are:
-
:belongs_to => container(default: nil) -
:name => :text_field(default: nil)
33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/rswing/components/combo_box.rb', line 33 def initialize(items = nil, = {}) if(items.kind_of? javax.swing.ComboBoxModel) super(items) elsif(items.kind_of? Array) super(items.to_java(:Object)) else super() end unless .empty? Container.add_if_requested(self, ) end end |
Instance Method Details
#[](item_index) ⇒ Object
Returns an item at a given index. Equivalent to ComboBox#item_at
49 50 51 |
# File 'lib/rswing/components/combo_box.rb', line 49 def [](item_index) self.item_at(item_index) end |
#items ⇒ Object
Returns the items of this ComboBox as an Array.
54 55 56 57 58 59 60 61 62 |
# File 'lib/rswing/components/combo_box.rb', line 54 def items @items = [] self.item_count.times do |i| @items << self[i] end @items end |