Creating an Observable List/Collection

Use the factory methods in FXCollections:

ObservableList<String> list = FXCollections.observableArrayList();

The unsafe operation in your choice box constructor is because you haven’t specified the type for the choice box:

ChoiceBox<String> box = new ChoiceBox<>(FXCollections.observableArrayList("Asparagus", "Beans", "Broccoli", "Cabbage" , "Carrot", "Celery", "Cucumber", "Leek", "Mushroom" , "Pepper", "Radish", "Shallot", "Spinach", "Swede" , "Turnip"));

and the error from SortedList is because there is no constructor taking no arguments. (Again, refer to the javadocs.) There are two constructors: the simplest one takes a reference to an ObservableList (the list for which the sorted list will provide a sorted view). So you would need something like

SortedList<String> sortedList = new SortedList<>(list);

or

SortedList<String> sortedList = new SortedList<>(FXCollections.observableArrayList());

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)