private static void createGUI() throws  MidiUnavailableException, InvalidMidiDataException, IOException {
	//Set up the GUI.
	dropdownFont = new Font("Dialog", Font.PLAIN, 12);

	// the main frame
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);



	// add icon for OS tray
	// This icon is also used in various dialogs
	java.net.URL iconURL = TemperamentStudio.class.getResource("icons/MMTIcon.png");
	theIcon = new ImageIcon(iconURL);
	frame.setIconImage(theIcon.getImage());
	
	// load gui help and license files
	/*
	guiusage = readStringFromJar("textfiles/GUIUsage.html");
	thingstotry =readStringFromJar("textfiles/ThingsToTry.html");
	*/
	
	// borders
	advancedSettingsBorder = BorderFactory.createLineBorder(Color.RED);
	sectionBorder = BorderFactory.createEtchedBorder();//BorderFactory.createLineBorder(Color.BLACK);


	// focus listener
	// This focus listener will be used to stop the keyboard dispatcher
	// from acting on keys typed.  It is used on elements that accept 
	// keystrokes so that the keys aren't also sent to other components
	blockKeysFocusListener = new FocusListener(){
		@Override
		public void focusGained(FocusEvent e){
		    catchKeyboard = false;
		    keyLockNotice.setOpaque(true);
		    keyLockNotice.setBackground(Color.red);
		    frame.repaint();
		}
		public void focusLost(FocusEvent e){
		    catchKeyboard = true;
		    keyLockNotice.setOpaque(false);
		    frame.repaint();
		}
	    };
	
	
	// the content pane for the main frame
	final Container contentPane = frame.getContentPane();
	contentPane.setLayout(new BoxLayout(contentPane,BoxLayout.Y_AXIS));



	///////////////////////////////////////////// make main GUI objects
	

	final JPanel topPanel = new JPanel();
	topPanel.setLayout(new BoxLayout(topPanel,BoxLayout.X_AXIS));

	JHelpPanel jHelpPanel = new JHelpPanel();
	
	// create panel to right of the help panel with tuning scheme, root note,
	// and other stuff
	//final JPanel jTopRightPanel = new JPanel();
	//jTopRightPanel.setLayout(new BoxLayout(jTopRightPanel,BoxLayout.Y_AXIS));

	// A panel to select tuning parameters
	jTuningSchemePanel = new JTuningSchemePanel();

	// A panel for advanced tuning settings
	jTuningAdvancedPanel = new JTuningAdvancedPanel(10,10);
	// This box will hold space for the advanced panel when it is not visible

	// A panel for midi file loading, saving, and playback
	final JPanel jFileSuperPanel = new JPanel(new FlowLayout());
	final JFilePanel jFilePanel = new JFilePanel();

	// A panel to play chords and intervals
	JChordIntervalPanel jChordIntervalPanel = new JChordIntervalPanel();

	// make the keyboard
	// This is the musical keyboard that you can click on
	// to play notes.
	//kbPanel = new KeyboardPanel();
	Synthesizer synth = MidiSystem.getSynthesizer();
	synth.open();
	kbPanel = new KeyboardPanel(synth, frame);




	/////////////////////////////////////////////////// add items to panels

	contentPane.add(topPanel);
	topPanel.add(jHelpPanel);
	topPanel.add(Box.createHorizontalGlue()); // slide jHelpPanel to the far left, other stuff to the right

	//topPanel.add(jTopRightPanel);

	topPanel.add(Box.createRigidArea(new Dimension(10,10)));	


       	topPanel.add(jTuningSchemePanel);

	// this panel has the options to show the file panel and the advanced panels
	final JPanel jOptionsPanel = new JPanel(new GridBagLayout());
	GridBagConstraints cop = new GridBagConstraints();
	

	final JCheckBox showFilePanelCheckBox = new JCheckBox("File Controls");
	
	showFilePanelCheckBox.addActionListener(new ActionListener() {
		public void actionPerformed(ActionEvent e){
		    if(showFilePanelCheckBox.isSelected()){
			jFileSuperPanel.add(jFilePanel);
			//frame.revalidate();
			frame.pack();
			frame.repaint();
		    }
		    else{
			jFileSuperPanel.remove(jFilePanel);
			frame.pack();
			frame.repaint();
		    }
		}
	    });
	cop.gridx=0;
	cop.gridy=0;
	jOptionsPanel.add(showFilePanelCheckBox,cop);

	advancedcheckbox = new JCheckBox("Advanced");
	//jTuningAdvancedPanel.setVisible(false);
	advancedcheckbox.addActionListener(new ActionListener() {
		public void actionPerformed(ActionEvent e) {
		    if(advancedcheckbox.isSelected()){
			jTuningAdvancedPanel.uncloak();//setVisible(true);
			jKeystringsPanel.uncloak();//setVisible(true);
			jFilePanel.addAdvancedPanel();
			//sineComboPanel.uncloak();//setVisible(true);
			jEditIntonationsPanel.uncloak();//.setVisible(true);
			frame.pack();
			frame.repaint();
		    }			
		    else{
			jFilePanel.removeAdvancedPanel();
			jTuningAdvancedPanel.cloak();//setVisible(false);
			jKeystringsPanel.cloak();//setVisible(false);
			//sineComboPanel.cloak();//setVisible(false);
			jEditIntonationsPanel.cloak();//.setVisible(false);
			frame.pack();
			frame.repaint();
		    }
		}
	    });
	cop.gridx = 1;
	cop.gridy = 0;
	jOptionsPanel.add(advancedcheckbox,cop);
	cop.gridx = 0;
	cop.gridy = 1;
	cop.gridwidth = 2;
	jOptionsPanel.add(jTuningAdvancedPanel,cop);
	
	

	topPanel.add(jOptionsPanel);

	//contentPane.add(Box.createRigidArea(new Dimension(10,10)));	

	JPanel jFileRowPanel = new JPanel();
	jFileRowPanel.setLayout(new BoxLayout(jFileRowPanel,BoxLayout.X_AXIS));
	jFileRowPanel.add(jFileSuperPanel);
	jBachChordPanel = new JPanel();
	jFileRowPanel.add(jBachChordPanel);



	contentPane.add(jFileRowPanel);

	// This panel has the musical keyboard as well as sub-panels to
	// add intervals, transpose notes, etc.
	JPanel keyboardSuperPanel = new JPanel();
	keyboardSuperPanel.setLayout(new BoxLayout(keyboardSuperPanel,BoxLayout.Y_AXIS));
	keyboardSuperPanel.setBorder(sectionBorder);
	jChordIntervalPanel.setAlignmentX(Component.CENTER_ALIGNMENT);
	keyboardSuperPanel.add(jChordIntervalPanel);
	kbPanel.setAlignmentX(Component.CENTER_ALIGNMENT);
	keyboardSuperPanel.add(kbPanel);
	JPanel belowKBPanel = new JPanel(new FlowLayout());
	//belowKBPanel.setBorder(sectionBorder);
	keyboardSuperPanel.add(belowKBPanel);
	

	JPanel sustainAndTransposePanel = new JPanel();
	sustainAndTransposePanel.setLayout(new BoxLayout(sustainAndTransposePanel,BoxLayout.Y_AXIS));
	//sustainAndTransposePanel.setBorder(sectionBorder);
	belowKBPanel.add(sustainAndTransposePanel);

	// Panel to change sustain, turn notes off
	JPanel kbSustainPanel = new JPanel(new FlowLayout());
	jKeyStrings = new JComboBox<String>();
	jKeyStrings.setFont(dropdownFont);
	jKeyStrings.addFocusListener(blockKeysFocusListener);
	jKeyStrings.addItem("None");
	jKeyStrings.addItem("Frequencies");
	jKeyStrings.addItem("Decimal Ratios");
	jKeyStrings.addItem("Integer Ratios");
	jKeyStrings.addItem("Note Names");
	jKeyStrings.addItem("MIDI Note Number");
	jKeyStrings.addItemListener(new ItemListener(){
		public void itemStateChanged(ItemEvent e) {
		    updateKeyStrings(jKeyStrings.getSelectedIndex());
		}
	    });
	jKeystringsPanel = new CloakablePanel(10,10);
	jKeystringsPanel.setLayout(new FlowLayout());
	jKeystringsPanel.add(new JLabel("Show:"));
	jKeystringsPanel.setBorder(advancedSettingsBorder);

	jKeystringsPanel.add(jKeyStrings);
	kbSustainPanel.add(jKeystringsPanel);
	//jKeystringsPanel.setVisible(false);

	jAllOff = new JButton("   ----  ALL NOTES OFF ----    (enter)");
	jAllOff.addActionListener(new ActionListener() {
		public void actionPerformed(ActionEvent e) {
		    kbPanel.allOff();
		}
	    });
	kbSustainPanel.add(jAllOff);
	kbPanel.sustainOn(true);
	jSustain.addActionListener(new ActionListener() {
		public void actionPerformed(ActionEvent e) {
		    if(jSustain.getText() == "sustain on (.)"){
			kbPanel.sustainOn(false);
			jSustain.setText("sustain off (.)");
		    }
		    else{
			kbPanel.sustainOn(true);
			jSustain.setText("sustain on (.)");
		    }
		}
	    });
	kbSustainPanel.add(jSustain);
	sustainAndTransposePanel.add(kbSustainPanel);


	// Panel to transpose notes up and down half steps and octaves
	JPanel kbTransposePanel = new JPanel();
	kbTransposePanel.setLayout(new GridBagLayout());
	GridBagConstraints c = new GridBagConstraints();
	c.fill = GridBagConstraints.HORIZONTAL;

	//	JPanel kbTransposePanelA = new JPanel(new FlowLayout());
	//kbTransposePanel.add(kbTransposePanelA);
	//JPanel kbTransposePanelB = new JPanel(new FlowLayout());
	//kbTransposePanel.add(kbTransposePanelB);

	jOctaveDown = new JButton("octave down (\u2193)");
	jOctaveDown.addActionListener(new ActionListener() {
		public void actionPerformed(ActionEvent e) {
		    kbPanel.downHalfSteps(12);
		}
	    });
	c.gridx = 0;
	c.gridy = 0;
	c.gridwidth = 2;
	c.gridheight = 1;
	kbTransposePanel.add(jOctaveDown,c);	


	jMoveDown = new JButton("1/2 step down (\u2190)");
	jMoveDown.addActionListener(new ActionListener() {
		public void actionPerformed(ActionEvent e) {
		    kbPanel.downHalfStep();
		}
	    });
	c.gridx = 2;
	c.gridy = 0;
	c.gridwidth = 2;
	c.gridheight = 1;
	kbTransposePanel.add(jMoveDown,c);	

        jMoveUp = new JButton("1/2 step up (\u2192)");
	jMoveUp.addActionListener(new ActionListener() {
		public void actionPerformed(ActionEvent e) {
		    kbPanel.upHalfStep();
		}
	    });
	c.gridx = 4;
	c.gridy = 0;
	c.gridwidth = 2;
	c.gridheight = 1;
	kbTransposePanel.add(jMoveUp,c);


	jOctaveUp = new JButton("octave up (\u2191)");
	jOctaveUp.addActionListener(new ActionListener() {
		public void actionPerformed(ActionEvent e) {
		    kbPanel.upHalfSteps(12);
		}
	    });
	c.gridx = 6;
	c.gridy = 0;
	c.gridwidth = 2;
	c.gridheight = 1;
	kbTransposePanel.add(jOctaveUp,c);
	sustainAndTransposePanel.add(kbTransposePanel);



	c.gridx = 0;
	c.gridy = 1;
	c.gridwidth = 1;
	c.gridheight = 1;
	kbTransposePanel.add(Box.createRigidArea(new Dimension(50,1)),c);
	
	JButton jFifthDown = new JButton("5th down");
	jFifthDown.addActionListener(new ActionListener() {
		public void actionPerformed(ActionEvent e) {
		    kbPanel.downHalfSteps(7);
		}
	    });
	c.gridx = 1;
	c.gridy = 1;
	c.gridwidth = 1;
	c.gridheight = 1;
	kbTransposePanel.add(jFifthDown,c);	

	JButton jFourthDown = new JButton("4th down");
	jFourthDown.addActionListener(new ActionListener() {
		public void actionPerformed(ActionEvent e) {
		    kbPanel.downHalfSteps(5);
		}
	    });
	c.gridx = 2;
	c.gridy = 1;
	c.gridwidth = 1;
	c.gridheight = 1;
	kbTransposePanel.add(jFourthDown,c);	


	c.gridx = 3;
	c.gridy = 1;
	c.gridwidth = 1;
	c.gridheight = 1;
	kbTransposePanel.add(Box.createRigidArea(new Dimension(50,1)),c);


	c.gridx = 4;
	c.gridy = 1;
	c.gridwidth = 1;
	c.gridheight = 1;
	kbTransposePanel.add(Box.createRigidArea(new Dimension(50,1)),c);

	JButton jFourthUp = new JButton("4th up");
	jFourthUp.addActionListener(new ActionListener() {
		public void actionPerformed(ActionEvent e) {
		    kbPanel.upHalfSteps(5);
		}
	    });
	c.gridx = 5;
	c.gridy = 1;
	c.gridwidth = 1;
	c.gridheight = 1;
	kbTransposePanel.add(jFourthUp,c);	

	JButton jFifthUp = new JButton("5th up");
	jFifthUp.addActionListener(new ActionListener() {
		public void actionPerformed(ActionEvent e) {
		    kbPanel.upHalfSteps(7);
		}
	    });
	c.gridx = 6;
	c.gridy = 1;
	c.gridwidth = 1;
	c.gridheight = 1;
	kbTransposePanel.add(jFifthUp,c);	

	c.gridx = 7;
	c.gridy = 1;
	c.gridwidth = 1;
	c.gridheight = 1;
	kbTransposePanel.add(Box.createRigidArea(new Dimension(50,1)),c);

	//keyboardSuperPanel.add(Box.createRigidArea(new Dimension(20,20)));
	
	jHarmonicsPanel = new CloakablePanel(0,0);
	jHarmonicsPanel.setBorder(sectionBorder);
	jHarmonicsPanel.setLayout(new BoxLayout(jHarmonicsPanel,BoxLayout.Y_AXIS));
	JLabel harmonicsLabel = new JLabel("Harmonics");
	harmonicsLabel.setAlignmentX(CENTER_ALIGNMENT);
	jHarmonicsPanel.add(harmonicsLabel);
	JPanel jHarmonicsSliderPanel = new JPanel();
	jHarmonicsSliderPanel.setLayout(new BoxLayout(jHarmonicsSliderPanel,BoxLayout.X_AXIS));
	jHarmonicsSliderPanel.setOpaque(true);
	jHarmonicsSliderPanel.setBackground(Color.DARK_GRAY);

	jHarmonicsSliders = new JSlider[nHarmonics];
	JLabel harmonicSliderLabels[] = new JLabel[nHarmonics];
	for(int i = 0; i < nHarmonics; i++){
	    harmonicSliderLabels[i] = new JLabel("n="+Integer.toString(i+1));
	    harmonicSliderLabels[i].setForeground(Color.WHITE);
	    jHarmonicsSliderPanel.add(harmonicSliderLabels[i]);
	    jHarmonicsSliders[i] = new JSlider(JSlider.VERTICAL,0,100,0);
	    jHarmonicsSliders[i].setOpaque(true);
	    jHarmonicsSliders[i].setBackground(Color.DARK_GRAY);
	    jHarmonicsSliders[i].addFocusListener(blockKeysFocusListener);
	    jHarmonicsSliderPanel.add(jHarmonicsSliders[i]);
	    jHarmonicsSliders[i].setValue(0);
	}
	jHarmonicsSliders[0].setValue(100);
	// set up action listeners last so that they don't get fired when we set values
	for(int i = 0; i < nHarmonics; i++){
	    jHarmonicsSliders[i].addChangeListener(new ChangeListener() {
		    public void stateChanged(ChangeEvent e){
			JSlider source = (JSlider) e.getSource();
			for(int j=0; j < nHarmonics; j++){
			    if(source == jHarmonicsSliders[j]){
				kbPanel.setHarmonic(j,jHarmonicsSliders[j].getValue());
			    }
			}
		    }
		});

	    
	}

	
	//jHarmonicsPanel.add(Box.createRigidArea(new Dimension(25,25)));
	jHarmonicsPanel.add(jHarmonicsSliderPanel);
	//jHarmonicsPanel.add(Box.createRigidArea(new Dimension(25,25)));
	jHarmonicsPanel.setPreferredSize(new Dimension(jHarmonicsPanel.getPreferredSize().width+10,kbSustainPanel.getPreferredSize().height+kbTransposePanel.getPreferredSize().height+10));
	belowKBPanel.add(jHarmonicsPanel);
	

	
	contentPane.add(keyboardSuperPanel);

	// make panel to display software version and licensing info
	JPanel infoPanel = new JPanel(new FlowLayout());
	contentPane.add(infoPanel);
	JLabel infotextarea = new JLabel(licensestring);
	Font thefont = new Font("Times Roman", Font.ITALIC, 10);
	infotextarea.setFont(thefont);
	infoPanel.add(infotextarea);

	contentPane.add(Box.createRigidArea(new Dimension(2,2)));
	
        //Display the window.

    }