title: how do i keep the items in a comboBox from duplicating in javafx?
body: <p>I made a single  editable combo box.....and when you type something in it whatever you type goes to the bottom of the list. The problem i am having is when i click on something that is already in the combo box it doesn't just get selected it also adds again into the combo box as a new entry creating a "Duplicate" any ideas on how i can prevent that? here is what i have.</p>
  
  <pre><code>import javafx.scene.*;
  import javafx.scene.control.*;
  import javafx.scene.layout.GridPane;
  import javafx.geometry.*;
  import javafx.stage.*;
  import javafx.application.Application;
  import javafx.collections.FXCollections;
  import javafx.collections.ObservableList;
  
  public class ComboBoxProblem extends Application {
  
  Scene scene1;
  
  ObservableList&lt;String&gt; randomStrings;
  
  
  
  
  
   public void start(Stage primaryStage)throws Exception{
      primaryStage.setTitle("ComboBox Problem!");
      primaryStage.setResizable(false);
      primaryStage.sizeToScene();
  
      GridPane gridPane = new GridPane();
  
      scene1 = new Scene(gridPane);
  
      ComboBox&lt;String&gt; box1 = new ComboBox&lt;String&gt;();
  
      randomStrings = FXCollections.observableArrayList(
              "Cool","Dude","BRO!","Weirdo","IDK"
  
     );   
  
  
  
     box1.setItems(randomStrings);
  
     box1.setEditable(true);
  
     box1.setValue(null);
     box1.setOnAction(event -&gt; {
        String value =
  
         box1.valueProperty().getValue();
  
  
         if( value != String.valueOf(randomStrings)){
  
  
             randomStrings.addAll(box1.valueProperty().getValue());
             box1.setValue(null);
         }
  
  
     });
     gridPane.setAlignment(Pos.CENTER);
     gridPane.setConstraints(box1,0,0);
  
  
  
     gridPane.getChildren().addAll(box1);
  
  
     primaryStage.setScene(scene1);
     primaryStage.show();
  
    }
  
  
  
  
    public static void main(String[] args) {
      launch(args);
  
    }
  
    }
  </code></pre>