@Override
        public void serialEvent(SerialPortEvent ev) {
            if (ev.getEventType() == SerialPortEvent.DATA_AVAILABLE) {
                try {
                    int available = inputStream.available();
                    byte[] receiveBuffer = new byte[available];
                    inputStream.read(receiveBuffer, 0, receiveBuffer.length);
                    String received;
                    if (byteJRadioButton.isSelected()) {
                        received = "";
                        for (int i = 0; i < available; i++) {
                            received += Byte.toString(receiveBuffer[i]) + ' ';
                        }
                        received += CR;
                    }
                    else {
                        received = new String(receiveBuffer);
                    }
                    receivedText.append(received);
                    if (receivedText.getText().length() > 50000) {
                        receivedText.replaceRange("", 0, 1000);
                    }
                    shouldScroll = true;
                }
                catch (IOException e) {
                    System.out.println(e);
                }
            }
        }