@FXML void fromComboBoxAction(ActionEvent event) { // fromComboBox.setItems(options); /* if(fromClicked && toClicked && !lastClicked.equals("from")){ fromBoxList.setAll(options); toBoxList.setAll(options); toClicked=false; System.out.println("both combo box has been clicked"); } */ /*System.out.println("now fromBoxList of size "+ fromBoxList.size()+ " will be setAll()"); fromComboBox.setItems(fromBoxList); */ // fromComboBox=new ComboBox(fromBoxList); String s = (String) fromComboBox.getValue(); c.setFrom(s); if (fromComboBox.getValue() == toComboBox.getValue()) { toComboBox .getSelectionModel() .clearSelection(); // to clear the selected option in the other combo box, because the // starting point and destination can't be the same c.setTo(null); // toComboBox.setButtonCell(null); // toComboBox.valueProperty().set(null); // toComboBox.getSelectionModel().clearSelection(); } // System.out.println(s.getClass()); // System.out.println(s); System.out.println("from " + s); // temp.remove(s); /* fromClicked=true; fromCombo=s; lastClicked="from"; //options.removeAll(s); if(fromClicked && !toClicked){ toBoxList.remove(fromCombo); System.out.println("removing "+fromCombo+" from the list and after removing, the size of the toBoxList= "+toBoxList.size()); toComboBox.setItems(toBoxList); } */ }