Sha256: 9771266bcd601630bade62d16d0030017e461463844be981c47188f7a4ea4329
Contents?: true
Size: 934 Bytes
Versions: 13
Compression:
Stored size: 934 Bytes
Contents
require 'swing/menu' require 'swing/menu_item' require 'swing/attr_setter' module Swing class MenuBar < javax.swing.JMenuBar include AttrSetter def initialize opts = {} set_attributes(opts) { super() } 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 = Menu.new menu_name.to_s, :parent => self menu_structure.each do |item_name, item_action| MenuItem.new item_name.to_s, :parent => menu, &item_action end end else self.add element end end end end end # Post-processing (non-setter) options given to initialize def self.add_component component, parent parent.setJMenuBar component if parent end end
Version data entries
13 entries across 13 versions & 1 rubygems