public void connect()
    {
        String selectedPort = (String)window.cboxPorts.getSelectedItem();
        selectedPortIdentifier = (CommPortIdentifier)portMap.get(selectedPort);

        CommPort commPort = null;

        try
        {
            //the method below returns an object of type CommPort
            commPort = selectedPortIdentifier.open("HardPanel", TIMEOUT);
            
            //the CommPort object can be casted to a SerialPort object
            serialPort = (SerialPort)commPort;

            serialPort.setSerialPortParams(9600, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE);
            //for controlling GUI elements
            setConnected(true);

            window.conStatus.setForeground(new Color(0,128,0));
            window.conStatus.setText("Connected to Hard Panel on " + selectedPort);

            //CODE ON SETTING BAUD RATE ETC OMITTED
            //XBEE PAIR ASSUMED TO HAVE SAME SETTINGS ALREADY

            //enables the controls on the GUI if a successful connection is made
            //window.keybindingController.toggleControls();
        }
        catch (PortInUseException e)
        {
            window.conStatus.setForeground(Color.RED);
            window.conStatus.setText(selectedPort + " is in use. (" + e.toString() + ")");
        }
        catch (Exception e)
        {
            window.conStatus.setText("Failed to open " + selectedPort + "(" + e.toString() + ")");
            window.conStatus.setForeground(Color.RED);
        }
        
    }