Sha256: 19f208f08be54e2e8577950583ff91effe63258c3388d66c8b618af884a87c16
Contents?: true
Size: 957 Bytes
Versions: 2
Compression:
Stored size: 957 Bytes
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 post_process opts super # 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 = Swing::JMenu.new menu_name.to_s, :parent => self menu_structure.each do |item_name, item_action| Swing::JMenuItem.new item_name.to_s, :parent => menu, &item_action end end else self.add element end end end end # Proper way to add menu bar to its parent def attach_to parent parent.setJMenuBar self if parent and parent.respond_to? :setJMenuBar end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
swing-0.1.8 | lib/swing/j_menu_bar.rb |
swing-0.1.7 | lib/swing/j_menu_bar.rb |