Take all the values add them to a ListModel
DefaultListModel model = new DefaultListModel();
for (Info info : List) {
model.addElement(model);
}
Then add this model to each of your JList
s...
JList list1 = new JList(model);
JList list2 = new JList(model);
JList list3 = new JList(model);
JList list4 = new JList(model);
Now, here comes the funky part, create a ListCellRenderer
for each different way you want to display the data...
import java.awt.Component;
import javax.swing.DefaultListCellRenderer;
import javax.swing.JList;
public class ListTest {
public static void main(String[] args) {
}
public class InfoNameListCellRenderer extends DefaultListCellRenderer {
@Override
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
if (value instanceof Info) {
Info info = (Info)value;
value = info.getName(); // Or what ever getter you have available for such things
}
return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
}
}
}
And apply it to the appropriate list...
list1.setCellRenderer(new InfoNameListCellRenderer());
Remember, it's the models responsibility to model the data, it's the renderer's responsibility to renderer it. Don't change the model to meet your rendering requirements.
Take a look at Concepts: Editors and Renderers and Writing a Custom Cell Renderer for more details