could you please help me, how to change color of items showed in JList?
I'm making an user JList where I can see online and offline users, and I need the offline users to have different colors than online users.
My code for creating users
final String [] strings=database.getUsers(myLogin);
jList1.setModel(new javax.swing.AbstractListModel() {
@Override
public int getSize() { return strings.length; }
@Override
public Object getElementAt(int i) { return strings[i]; }
});
I think that you have to read tutorial How to Use Lists, especially part Writing a Custom Cell Renderer, concept of Renderer is the same for JList, JTable or for JComboBox too
examples are here and on this forum here