How to populate jList by the keys from Map collection? I have added jListCars to a jScrollPanel and now I want to populate jListCars by key Strings from Map. So far I have used demoList that is added to jListCars. However I will need often to add new vehicles and I dont want each time to be adding updated demoList to jListCars. Is there some better way to do it? Also user should be able to select the car in jListCars to get other information about the vehicle.
Map<String, Car> cars = new HasMap<>(); Set<String> keysCar = cars.keySet(); DefaultListModel demoList = new DefaultListModel(); public void createList() { for (String eachKey: keysCar) { demoList.addElement(eachKey); } jListCars.add(demoList); ????????
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)