private void okAppButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okAppButtonActionPerformed
        // TODO add your handling code here:
        try {
            appname = (String) appNameTextField.getText();
        } catch (NullPointerException ne) {
            dispose();
            JFrame mainFrame = FlexiSimApp.getApplication().getMainFrame();
            JOptionPane.showMessageDialog(mainFrame, "Application name must be specified.", "Agent Cannot be Created", JOptionPane.ERROR_MESSAGE);
            flag = false;

        }
        apptype = (String) appTypeComboBox.getSelectedItem();
        try {
            Number number = (Number) (startAppFormattedTextField.getValue());
            start = number.doubleValue();

        } catch (NullPointerException ne) {
            flag = false;
            dispose();
            JFrame mainFrame = FlexiSimApp.getApplication().getMainFrame();
            JOptionPane.showMessageDialog(mainFrame, "Start time of the application must be specified.", "Agent Cannot be Created", JOptionPane.ERROR_MESSAGE);
        }
        agent = NewAgent.agentNameTextField.getText();
        try {
            Number number = (Number) stopAppFormattedTextField.getValue();
            stop = number.doubleValue();
        } catch (Exception ie) {
            stop = 0;
        }
        if (flag) {
            if ((NewAgent.atype.equals("TCP") && apptype.equals("CBR")) || (NewAgent.atype.equals("UDP") && apptype.equals("FTP"))) {
                dispose();
                JFrame mainFrame = FlexiSimApp.getApplication().getMainFrame();
                JOptionPane.showMessageDialog(mainFrame, "Agents and their corresponding applications must be compatibe.", "Agent Cannot be Connected", JOptionPane.ERROR_MESSAGE);
            } else if (apptype.equals("CBR")) {
                JFrame mainFrame = FlexiSimApp.getApplication().getMainFrame();
                NewCBRTraffic newcbrtraffic = new NewCBRTraffic(mainFrame);
                newcbrtraffic.setLocationRelativeTo(mainFrame);
                FlexiSimApp.getApplication().show(newcbrtraffic);
                dispose();
            } else {
                NewProject.obam.addAgent(NewAgent.aname, NewAgent.atype, NewAgent.anode);
                NewNode.obj.agentWrite(NewAgent.aname, NewAgent.atype, NewAgent.anode);
                NewNode.obj.appWrite(appname, apptype, agent, 0, 0, false, -1, -1);
                NewNode.obj.eventWrite(start, stop, appname);
                NewProject.obappm.addApp(appname, apptype);
                FlexiSimView.statusTabbedPane.setSelectedIndex(0);
                FlexiSimView.statusTextArea.append("New Agent " + NewAgent.atype + " on " + NewAgent.anode + " has been created successfully\n");
                NewProject.obpd.setLog("New Agent " + NewAgent.atype + " on " + NewAgent.anode + " has been created successfully\n");
                FlexiSimView.codeTextAreaWrite();
                dispose();
            }
        }
    }//GEN-LAST:event_okAppButtonActionPerformed