the buttons are created from a List returned from port.getAvailablePorts(): (method from rxtx serial class)
for (int i = 0; i < port.getAvailablePorts().size(); i++){
JRadioButtonMenuItem e = new JRadioButtonMenuItem(port.getAvailablePorts().get(i));
RadioButtonsGroup.add(e);
menuItem.add(e);}
when I want to refresh the serial ports list, first I need to clear the button group, then rebuild it with the new buttons, but I can't clear it using remove() with values from port.getAvailablePorts() because they can change at any time.
I will try to store the buttons in a separate ArrayList, so I will feed the remove() method with its values, then clear the Arraylist, fill the ArrayList with the new values from port.getAvailablePorts(), create and add the buttons to the button group.