I have an Ingredient class
public class Ingredient { String NameP; List ListS; String Desc; List ListT; ...
multiple instances of this class are stored in the list of objects. I also have
javax.swing.JList ListIng;
A model is installed with it.
ListIngModel = new DefaultListModel();
The idea is to use a Jlist to display the "NameP" field of all objects, select one of them for further inspection, and then capture the selected object:
Ingredient Selected = ListIngModel.get(ListIng.getSelectedIndex())
I can load objects in a list model, but then the JList displays their address. Is there an elegant way to get it to display the property of the objects it stores?
source share