I have a class Test whose field can be changed in the program when selected in a JList. I've tried:
model = new DefaultListModel();
list = new JList(model);
model.addElement(new Test(1.0f));
but then I get Test@44322 in my JList. I want a black square and the String "Test" in my JList. What's the best way to achieve that?
I think the approach is quite OK, next step is to tell the list how to render an object Test, ie
list.setCellRenderer(...)
my 0.02€
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.