0

Java Beginners: connecting and storing three types of informations to work with them as a package?

Informations to collect, one each per user entry: A date (Datepicker) A String (Textfield, a name in this case) An option from a limited pool (Combobox) In the end, I want to check (get suggestions) on which dates all options from the limited pool are selected at least once and show the content of the text field input, too. My idea was to put the input in a HashSet. Date to string works, Textfield is a string anyways. But the Combobox refuses cooperation. It is fairly unimpressed by get Value, getSelectedItem and doesn't accept a simple toString. I tested most of the options I found on this via Google research but none of them work. The options in the Combobox are taken from an Array list, which contains simple Strings. (for human purposes, each item represents a human "to do task") I'm open for ideas/strategies for the overall task, since I am not sure it's a problem of the Combobox or if the general approach might create this problem. Thank you :) Note: it seems J-javastuff and JavaFX don't mix

12th Dec 2019, 1:27 PM
Alisa Jääkarhu
Alisa Jääkarhu - avatar
1 Respuesta
+ 1
I think there should be a way to make the combobox work. I found this: https://stackoverflow.com/questions/16437872/fxml-combobox-get-the-selected-value-into-javafx Probably this should work: combobox.getSelectionModel().getSelectedItem().toString(); To store the combination of the 3 fields, I would probably create a custom class (e.g. UserChoice) that contains these 3 fields.. Not necessarily all String, maybe you want LocalDate to store the date. Then you could make an ArrayList<UserChoice> or HashSet<UserChoice> depending how you want to process the information... And you may need to implement the equals() and hashCode() method in this class. https://www.journaldev.com/21095/java-equals-hashcode
22nd Jan 2020, 4:12 AM
Tibor Santa
Tibor Santa - avatar