+ 3
How can i add data from jcombobox to txt file in java?
2 Respostas
+ 2
here is the only answer I found but I don't know If this is what you are looking for
https://stackoverflow.com/a/3173295/7218253
+ 2
String s = "";
for(int i = 0; i < yourCombobox.getItemCount(); i++){
s += yourCombobox.getItemAt(i).toString() + "\n";
}
Now write 's' to file. To retrieve, read s from file and split("\n") to get your items in an array.
Note: Your items are saved as strings. Saving java object directly is possible but beyond the scope of this answer.