package edu.unl.consystlab.gui;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.HashMap;

import javax.swing.JMenu;
import javax.swing.JMenuItem;

public class HelpMenu extends JMenu implements ActionListener
{
	public HashMap map = new HashMap();

	public void actionPerformed(ActionEvent e)
	{
		Object o = e.getSource();
		if (!(o instanceof JMenuItem))
			return;
		JMenuItem jm = (JMenuItem)o;
		String title = jm.getActionCommand();
		String txt = (String)map.get(title);
		if (txt == null)
			return;
		Dialogs.info(null, title, txt);
	}

	public HelpMenu(String title)
	{
		super(title);
	}

	public void add(String title, String txt)
	{
		JMenuItem jm = new JMenuItem(title);
		jm.addActionListener(this);
		this.add(jm);
		map.put(title, txt);
	}
} // HelpMenu
