/* Generated by Together */ package gui; import java.io.FileNotFoundException; import javax.swing.JMenu; import javax.swing.JMenuItem; import javax.swing.ImageIcon; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.Locale; import java.net.URL; import evolution.InfoList; public class InfoMenu extends JMenu { public InfoMenu(InfoList infoList, String menuName, String menuIconPath) { super(menuName); this.infoList = infoList; this.menuIconPath = menuIconPath; init(); } protected void init() { while (infoList.next()) { JMenuItem menuItem; if (infoList.getType() == InfoList.STRING) { URL url = ClassLoader.getSystemResource(menuIconPath + infoList.getName() + ".gif"); if (url != null) { ImageIcon icon = new ImageIcon(url); menuItem = new JMenuItem(infoList.getName(), icon); } else menuItem = new JMenuItem(infoList.getString()); menuItem.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent evt) { String actionCommand = evt.getActionCommand(); selectActionPerformed(actionCommand); } }); add(menuItem); } } } protected void selectActionPerformed(String actionCommand) { } private String menuIconPath; private InfoList infoList; }