I want to make the text as a list but it is still in one line.
Here is my code:
model.addElement(new Product("Bags", "Prada Gucci Herschel Hawk CLN"));
model.addElement(new Product("Watches", "Timex \n Tissot \n Swatch \n Casio \n Seiko"));
model.addElement(new Product("Shoes", "Under Armour \n Nike \n Vans \n Adidas \n Timberland"));
model.addElement(new Product("Jewelry", "Cartier \n Pandora \n Mikimoto \n Bulgari \n Foundrae"));
model.addElement(new Product("Car", "Toyota \n Mitsubishi \n Tesla \n Suzuki \n Honda"));
list.getSelectionModel().addListSelectionListener(e -> {
Product p = list.getSelectedValue();
label.setText("Items: " + p.getItem());
});
Here is the output:
