I'm trying to figure out how to make the box of the new data that was entered into my List after into a selected box after entering it. I implemented the getSelectionModel() method to where I can click on any item of the list but I want the new data that I entered to be selected (to have the blue/gray box around it) after I add new data. I have this code that adds new data into the list but I'm not sure if listView.getSelectionModel().select(name);
is the way to get the result that I want.
String newLine = name + "," + artist + "," + year + "," + album;
obsList.add(name.trim() + " " + artist.trim());
writeToFile(newLine);
nameBox.setText(name);
artistBox.setText(artist);
albumBox.setText(year);
yearBox.setText(year);
listView.getSelectionModel().select(name); //this is what I added to try to select the box after I added new info
sortOBS();
This is how my List pops up as when I run code.
This is how my List looks like after I enter new data.
I want the new data that I entered to be selected after I add to the list. In other words, how do I get the item that I added to be selected (blue/gray box around it)after entering new data?