public JMenuBar createGUI(boolean useFrame) {
        useFrame = true;//tmp
        mainMenu = new JPopupMenu();
        JMenuBar mb = null;
        if (useFrame) {
            mb = new JMenuBar();
        }
        JMenu m = new JMenu("File");
        if (useFrame) {
            mb.add(m);
        } else {
            mainMenu.add(m);
        }
        m.add(importItem = getMenuItem("Import"));
        m.add(exportItem = getMenuItem("Export"));
        m.add(exportLinkItem = getMenuItem("Export Link"));
        m.addSeparator();

        m = new JMenu("Edit");
        m.add(undoItem = getMenuItem("Undo"));
        undoItem.setAccelerator(KeyStroke.getKeyStroke('Z', KeyEvent.CTRL_DOWN_MASK));
        m.add(redoItem = getMenuItem("Redo"));
        redoItem.setAccelerator(KeyStroke.getKeyStroke('Z', KeyEvent.CTRL_DOWN_MASK | KeyEvent.SHIFT_DOWN_MASK));
        m.addSeparator();
        m.add(cutItem = getMenuItem("Cut"));
        cutItem.setAccelerator(KeyStroke.getKeyStroke('X', KeyEvent.CTRL_DOWN_MASK));
        m.add(copyItem = getMenuItem("Copy"));
        copyItem.setAccelerator(KeyStroke.getKeyStroke('C', KeyEvent.CTRL_DOWN_MASK));
        m.add(pasteItem = getMenuItem("Paste"));
        pasteItem.setAccelerator(KeyStroke.getKeyStroke('V', KeyEvent.CTRL_DOWN_MASK));
//        pasteItem.setEnabled(false);
        m.add(selectAllItem = getMenuItem("Select All"));
        selectAllItem.setAccelerator(KeyStroke.getKeyStroke('A', KeyEvent.CTRL_DOWN_MASK));
        if (useFrame) {
            mb.add(m);
        } else {
            mainMenu.add(m);
        }

        m = new JMenu("Scope");
        if (useFrame) {
            mb.add(m);
        } else {
            mainMenu.add(m);
        }
        m.add(getMenuItem("Stack All", "stackAll"));
        m.add(getMenuItem("Unstack All", "unstackAll"));

        optionsMenu = m = new JMenu("Options");
        if (useFrame) {
            mb.add(m);
        } else {
            mainMenu.add(m);
        }
        m.add(dotsCheckItem = getCheckItem("Show Current"));
        dotsCheckItem.setState(true);
        m.add(voltsCheckItem = getCheckItem("Show Voltage"));
        voltsCheckItem.setState(true);
        m.add(powerCheckItem = getCheckItem("Show Power"));
        m.add(showValuesCheckItem = getCheckItem("Show Values"));
        showValuesCheckItem.setState(true);
        //m.add(conductanceCheckItem = getCheckItem("Show Conductance"));
        m.add(smallGridCheckItem = getCheckItem("Small Grid"));
        m.add(euroResistorCheckItem = getCheckItem("European Resistors"));
        euroResistorCheckItem.setState(sim.euroResistor());
        m.add(printableCheckItem = getCheckItem("White Background"));
        printableCheckItem.setState(sim.whiteBackground());
        m.add(conventionCheckItem = getCheckItem("Conventional Current Motion"));
//        conventionCheckItem.setState(convention); //TODO
        m.add(optionsItem = getMenuItem("Other Options..."));

        mainMenu.add(getClassCheckItem("Add Wire", "WireElm"));
        mainMenu.add(getClassCheckItem("Add Resistor", "ResistorElm"));

        JMenu passMenu = new JMenu("Passive Components");
        mainMenu.add(passMenu);
        passMenu.add(getClassCheckItem("Add Capacitor", "CapacitorElm"));
        passMenu.add(getClassCheckItem("Add Inductor", "InductorElm"));
        passMenu.add(getClassCheckItem("Add Switch", "SwitchElm"));
        passMenu.add(getClassCheckItem("Add Push Switch", "PushSwitchElm"));
        passMenu.add(getClassCheckItem("Add SPDT Switch", "Switch2Elm"));
        passMenu.add(getClassCheckItem("Add Potentiometer", "PotElm"));
        passMenu.add(getClassCheckItem("Add Transformer", "TransformerElm"));
        passMenu.add(getClassCheckItem("Add Tapped Transformer",
                "TappedTransformerElm"));
        passMenu.add(getClassCheckItem("Add Transmission Line", "TransLineElm"));
        passMenu.add(getClassCheckItem("Add Relay", "RelayElm"));
        passMenu.add(getClassCheckItem("Add Memristor", "MemristorElm"));
        passMenu.add(getClassCheckItem("Add Spark Gap", "SparkGapElm"));

        JMenu inputMenu = new JMenu("Inputs/Outputs");
        mainMenu.add(inputMenu);
        inputMenu.add(getClassCheckItem("Add Ground", "GroundElm"));
        inputMenu.add(getClassCheckItem("Add Voltage Source (2-terminal)", "DCVoltageElm"));
        inputMenu.add(getClassCheckItem("Add A/C Source (2-terminal)", "ACVoltageElm"));
        inputMenu.add(getClassCheckItem("Add Voltage Source (1-terminal)", "RailElm"));
        inputMenu.add(getClassCheckItem("Add A/C Source (1-terminal)", "ACRailElm"));
        inputMenu.add(getClassCheckItem("Add Square Wave (1-terminal)", "SquareRailElm"));
        inputMenu.add(getClassCheckItem("Add Analog Output", "OutputElm"));
        inputMenu.add(getClassCheckItem("Add Logic Input", "LogicInputElm"));
        inputMenu.add(getClassCheckItem("Add Logic Output", "LogicOutputElm"));
        inputMenu.add(getClassCheckItem("Add Clock", "ClockElm"));
        inputMenu.add(getClassCheckItem("Add A/C Sweep", "SweepElm"));
        inputMenu.add(getClassCheckItem("Add Var. Voltage", "VarRailElm"));
        inputMenu.add(getClassCheckItem("Add Antenna", "AntennaElm"));
        inputMenu.add(getClassCheckItem("Add AM source", "AMElm"));
        inputMenu.add(getClassCheckItem("Add FM source", "FMElm"));
        inputMenu.add(getClassCheckItem("Add Current Source", "CurrentElm"));
        inputMenu.add(getClassCheckItem("Add LED", "LEDElm"));
        inputMenu.add(getClassCheckItem("Add Lamp (beta)", "LampElm"));
        inputMenu.add(getClassCheckItem("Add LED Matrix", "LEDMatrixElm"));
        //inputMenu.add(getClassCheckItem("Add Microphone Input", "SignalInElm"));
        //inputMenu.add(getClassCheckItem("Add Speaker Output", "SignalOutElm"));

        JMenu activeMenu = new JMenu("Active Components");
        mainMenu.add(activeMenu);
        activeMenu.add(getClassCheckItem("Add Diode", "DiodeElm"));
        activeMenu.add(getClassCheckItem("Add Zener Diode", "ZenerElm"));
        activeMenu.add(getClassCheckItem("Add Transistor (bipolar, NPN)",
                "NTransistorElm"));
        activeMenu.add(getClassCheckItem("Add Transistor (bipolar, PNP)",
                "PTransistorElm"));
        activeMenu.add(getClassCheckItem("Add Op Amp (- on top)", "OpAmpElm"));
        activeMenu.add(getClassCheckItem("Add Op Amp (+ on top)",
                "OpAmpSwapElm"));
        activeMenu.add(getClassCheckItem("Add MOSFET (n-channel)",
                "NMosfetElm"));
        activeMenu.add(getClassCheckItem("Add MOSFET (p-channel)",
                "PMosfetElm"));
        activeMenu.add(getClassCheckItem("Add JFET (n-channel)",
                "NJfetElm"));
        activeMenu.add(getClassCheckItem("Add JFET (p-channel)",
                "PJfetElm"));
        activeMenu.add(getClassCheckItem("Add Analog Switch (SPST)", "AnalogSwitchElm"));
        activeMenu.add(getClassCheckItem("Add Analog Switch (SPDT)", "AnalogSwitch2Elm"));
        activeMenu.add(getClassCheckItem("Add Tristate buffer", "TriStateElm"));
        activeMenu.add(getClassCheckItem("Add Schmitt Trigger", "SchmittElm"));
        activeMenu.add(getClassCheckItem("Add Schmitt Trigger (Inverting)", "InvertingSchmittElm"));
        activeMenu.add(getClassCheckItem("Add SCR", "SCRElm"));
        //activeMenu.add(getClassCheckItem("Add Varactor/Varicap", "VaractorElm"));
        activeMenu.add(getClassCheckItem("Add Tunnel Diode", "TunnelDiodeElm"));
        activeMenu.add(getClassCheckItem("Add Triode", "TriodeElm"));
        //activeMenu.add(getClassCheckItem("Add Diac", "DiacElm"));
        //activeMenu.add(getClassCheckItem("Add Triac", "TriacElm"));
//        activeMenu.add(getClassCheckItem("Add Photoresistor", "PhotoResistorElm"));
        //activeMenu.add(getClassCheckItem("Add Thermistor", "ThermistorElm"));
        activeMenu.add(getClassCheckItem("Add CCII+", "CC2Elm"));
        activeMenu.add(getClassCheckItem("Add CCII-", "CC2NegElm"));

        JMenu gateMenu = new JMenu("Logic Gates");
        mainMenu.add(gateMenu);
        gateMenu.add(getClassCheckItem("Add Inverter", "InverterElm"));
        gateMenu.add(getClassCheckItem("Add NAND Gate", "NandGateElm"));
        gateMenu.add(getClassCheckItem("Add NOR Gate", "NorGateElm"));
        gateMenu.add(getClassCheckItem("Add AND Gate", "AndGateElm"));
        gateMenu.add(getClassCheckItem("Add OR Gate", "OrGateElm"));
        gateMenu.add(getClassCheckItem("Add XOR Gate", "XorGateElm"));

        JMenu chipMenu = new JMenu("Chips");
        mainMenu.add(chipMenu);
        chipMenu.add(getClassCheckItem("Add D Flip-Flop", "DFlipFlopElm"));
        chipMenu.add(getClassCheckItem("Add JK Flip-Flop", "JKFlipFlopElm"));
        chipMenu.add(getClassCheckItem("Add T Flip-Flop", "TFlipFlopElm"));
        chipMenu.add(getClassCheckItem("Add 7 Segment LED", "SevenSegElm"));
        chipMenu.add(getClassCheckItem("Add 7 Segment Decoder", "SevenSegDecoderElm"));
        chipMenu.add(getClassCheckItem("Add Multiplexer", "MultiplexerElm"));
        chipMenu.add(getClassCheckItem("Add Demultiplexer", "DeMultiplexerElm"));
        chipMenu.add(getClassCheckItem("Add SIPO shift register", "SipoShiftElm"));
        chipMenu.add(getClassCheckItem("Add PISO shift register", "PisoShiftElm"));
        chipMenu.add(getClassCheckItem("Add Phase Comparator", "PhaseCompElm"));
        chipMenu.add(getClassCheckItem("Add Counter", "CounterElm"));
        chipMenu.add(getClassCheckItem("Add Decade Counter", "DecadeElm"));
        chipMenu.add(getClassCheckItem("Add 555 Timer", "TimerElm"));
        chipMenu.add(getClassCheckItem("Add DAC", "DACElm"));
        chipMenu.add(getClassCheckItem("Add ADC", "ADCElm"));
        chipMenu.add(getClassCheckItem("Add Latch", "LatchElm"));
        //chipMenu.add(getClassCheckItem("Add Static RAM", "SRAMElm"));
        chipMenu.add(getClassCheckItem("Add Sequence generator", "SeqGenElm"));
        chipMenu.add(getClassCheckItem("Add VCO", "VCOElm"));
        chipMenu.add(getClassCheckItem("Add Full Adder", "FullAdderElm"));
        chipMenu.add(getClassCheckItem("Add Half Adder", "HalfAdderElm"));

        JMenu otherMenu = new JMenu("Other");
        mainMenu.add(otherMenu);
        otherMenu.add(getClassCheckItem("Add Text", "TextElm"));
        otherMenu.add(getClassCheckItem("Add Box", "BoxElm"));
        otherMenu.add(getClassCheckItem("Add Scope Probe", "ProbeElm"));
        otherMenu.add(getCheckItem("Drag All (Alt-drag)", "DragAll"));
        otherMenu.add(getCheckItem(
                sim.isMac ? "Drag Row (Alt-S-drag, S-right)"
                        : "Drag Row (S-right)",
                "DragRow"));
        otherMenu.add(getCheckItem(
                sim.isMac ? "Drag Column (Alt-\u2318-drag, \u2318-right)"
                        : "Drag Column (C-right)",
                "DragColumn"));
        otherMenu.add(getCheckItem("Drag Selected", "DragSelected"));
        otherMenu.add(getCheckItem("Drag Post (" + sim.ctrlMetaKey + "-drag)",
                "DragPost"));

        mainMenu.add(getCheckItem("Select/Drag Selected (space or Shift-drag)", "Select"));
        sim.getContainer().add(mainMenu);

        createSideBar(mb, useFrame, sim.getContainer());

//        if (useFrame) {
//            setMenuBar(mb);
//        }
        return mb;
    }