/*
 *
 * Copyright (C)  30-août-2003 Jean-Yves Beaujean 
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the Free
 * Software Foundation; either version 2 of the License, or (at your option)
 * any later version.
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 * more details.
 * You should have received a copy of the GNU General Public License along with
 * this program; if not, write to the Free Software Foundation, Inc.,  59
 * Temple Place - Suite 330, Boston, MA 02111-1307, USA.

 * 
 */
package jxtray.swing;


import javax.swing.JMenuBar;
import jxtray.JxtFrame;
import jxtray.Jxtray;
import jxtray.JxtrayConstants;
import jxtray.Messages;

import org.xml.sax.ContentHandler;
import org.xml.sax.XMLReader;
import org.xml.sax.InputSource;
import org.xml.sax.helpers.XMLReaderFactory;


public class JxtMenuBar extends JMenuBar
 {
 		private JxtMenuListener listener;
 		public JxtMenuBar(JxtFrame parent )
 		{
 				listener = new JxtMenuListener(parent);
				this.setFont(Jxtray.getFont());
 				buildMenu();
 		}
 		
 		private void buildMenu()
 		{
				try
				{
				
					XMLReader reader = XMLReaderFactory.createXMLReader(JxtrayConstants.XMLPARSER);
					ContentHandler jmenubarHandler = new  JMenuBarContentHandler(this,listener);
					reader.setContentHandler(jmenubarHandler);
					//	ANALYSE
					//String xmlURI = "file:///"+Jxtray.APPHOME+"share"+File.separator+"lang"+File.separator+"menu_"+Jxtray.getProperty("lang").toLowerCase()+".xml";
					InputSource inputSource = new InputSource(getClass().getResourceAsStream("/share/lang/menu_"+Jxtray.getProperty("lang").toLowerCase()+".xml"));
					reader.parse(inputSource);
				}
				catch ( Exception e )
				{
						Messages.error("JxtMenuBar.init() : "+ e );
				}
				
				
 			
 		}

}
