import java.awt.*;

public class GUIManager extends Frame {
    boolean inAnApplet = true;
    final String FILEDIALOGMENUITEM = "File dialog...";

    public GUIManager() {
        Panel bottomPanel = new Panel();
        Panel centerPanel = new Panel();

        MenuBar mb = new MenuBar();
        Menu m_file = new Menu("File");
        m_file.add(new MenuItem("New"));
        m_file.add(new MenuItem("Open"));
//        m_file.add(new MenuItem(FILEDIALOGMENUITEM));
	Menu m_file_save = new Menu("Save");
	m_file_save.add(new MenuItem("All"));
	m_file_save.add(new MenuItem("Physical"));
	m_file_save.add(new MenuItem("Network"));
        m_file.add(m_file_save);
        m_file.add(new MenuItem("Close"));
        m_file.add(new MenuItem("-"));
        m_file.add(new MenuItem("Revert to Saved"));
        m_file.add(new MenuItem("Quit"));
        mb.add(m_file);

	Menu m_edit = new Menu("Edit");
 	Menu m_edit_clear = new Menu("Clear");
	m_edit_clear.add(new MenuItem("All"));
	m_edit_clear.add(new MenuItem("Physical"));
	m_edit_clear.add(new MenuItem("Network"));

 	Menu m_edit_insert = new Menu("Insert");
	m_edit_insert.add(new MenuItem("All"));
	m_edit_insert.add(new MenuItem("Physical"));
	m_edit_insert.add(new MenuItem("Network"));

 	Menu m_edit_add = new Menu("Add");
	m_edit_add.add(new MenuItem("Switch"));
	m_edit_add.add(new MenuItem("Link"));
	m_edit_add.add(new MenuItem("Switch Set"));
        m_edit_add.add(new MenuItem("-"));
	m_edit_add.add(new MenuItem("Place"));
	m_edit_add.add(new MenuItem("Conduit"));
        m_edit_add.add(new MenuItem("-"));
        m_edit_add.add(new MenuItem("Constraint"));

 	Menu m_edit_del = new Menu("Delete");
	m_edit_del.add(new MenuItem("Switch"));
	m_edit_del.add(new MenuItem("Link"));
	m_edit_del.add(new MenuItem("Switch Set"));
        m_edit_del.add(new MenuItem("-"));
	m_edit_del.add(new MenuItem("Place"));
	m_edit_del.add(new MenuItem("Conduit"));
        m_edit_del.add(new MenuItem("-"));
        m_edit_del.add(new MenuItem("Constraint"));

        m_edit.add(new MenuItem("Undo"));
        m_edit.add(new MenuItem("Redo"));
        m_edit.add(new MenuItem("-"));
        m_edit.add(m_edit_clear);
        m_edit.add(m_edit_insert);
        m_edit.add(m_edit_add);
        m_edit.add(m_edit_del);
        mb.add(m_edit);

        Menu m_options = new Menu("Options");
        m_options.add(new MenuItem("Display"));
        m_options.add(new MenuItem("Scale"));
        m_options.add(new MenuItem("Units"));
        m_options.add(new MenuItem("Configuration"));
        mb.add(m_options);

        Menu m_optimize = new Menu("Optimize");
        m_optimize.add(new MenuItem("Star"));
	Menu m_opt_Part = new Menu("Partitioning");
	m_opt_Part.add(new MenuItem("Hierarchical"));
	m_opt_Part.add(new MenuItem("Triangular"));
        m_optimize.add(m_opt_Part);
        mb.add(m_optimize);

        Menu m_window = new Menu("Window");
        m_window.add(new MenuItem("Cascade"));
        m_window.add(new MenuItem("Tile Horizontal"));
        m_window.add(new MenuItem("Tile Vertical"));
        m_window.add(new MenuItem("-"));
        m_window.add(new MenuItem("Links"));
        m_window.add(new MenuItem("Conduits"));
        m_window.add(new MenuItem("Switches"));
        m_window.add(new MenuItem("Places"));
        m_window.add(new MenuItem("-"));
        m_window.add(new MenuItem("Switch Sets"));
        m_window.add(new MenuItem("-"));
        mb.add(m_window);

        Menu m_help = new Menu("Help");
        m_help.add(new MenuItem("About"));
        m_help.add(new MenuItem("-"));
        m_help.add(new MenuItem("Using Network Design Tool"));
        m_help.add(new MenuItem("Algorithm Documentation"));
        m_help.add(new MenuItem("-"));
        mb.add(m_help);

        setMenuBar(mb);

        //Put a label and a text area in the right column.
        Panel p = new Panel();
        p.setLayout(new BorderLayout());
        p.add("North", new Label("Current Network", Label.CENTER));
        p.add("Center", new TextArea("", 25, 50));
        centerPanel.add(p);

        setLayout(new BorderLayout());
        add("South", bottomPanel);
        add("Center", centerPanel);

    }

    public boolean handleEvent(Event evt) {
        if ((evt.id == Event.ACTION_EVENT) 
            && (evt.target instanceof MenuItem)) {
            String label = (String)evt.arg;
            if (label.equals(FILEDIALOGMENUITEM)) {
                FileDialog fd = new FileDialog(this, "FileDialog");
                fd.show();
            }
            return true;
        } 
        if (evt.id == Event.WINDOW_ICONIFY) {//DOESN'T seem to be necessary
            hide();
            return true;
        }
        if (evt.id == Event.WINDOW_DESTROY) {
            if (inAnApplet) {
                dispose();
                return true;
            } else {
                System.exit(0);
            }
        }
        return super.handleEvent(evt);
    }

    public static void main(String args[]) {
        GUIManager window = new GUIManager();
        window.inAnApplet = false;

        //window.setTitle(window.getClass().getName() + " Application");
        window.setTitle("Network Design Tool");
        window.pack();
        window.show();
    }

}




