Sha256: 6a763166e8210cad0f728faf93b0fcfcd5220b056b6aa6c8158119f3037e1603

Contents?: true

Size: 1 KB

Versions: 1

Compression:

Stored size: 1 KB

Contents

require 'swing'
require 'swing/j_menu'
require 'swing/j_menu_item'

class Swing::JMenuBar

  attr_setter :tool_tip_text

  # Override post-processing (non-setter) options given to initialize
  def self.post_process component, opts
    # Create menu structure from :structure opt
    if opts[:structure]
      [opts[:structure]].flatten.each do |element|
        case element
          when Hash # Hash defines menu structure
            element.each do |menu_name, menu_structure|
              menu = JMenu.new menu_name.to_s, :parent => self
              menu_structure.each do |item_name, item_action|
                JMenuItem.new item_name.to_s, :parent => menu, &item_action
              end
            end
          else
            component.add element
        end
      end
    end
    add_component component, opts[:parent]
  end

  # Proper way to add menu bar to its parent
  def self.add_component component, parent
    parent.setJMenuBar component if parent and parent.respond_to? :setJMenuBar
  end


end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
swing-0.1.5 lib/swing/j_menu_bar.rb