File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes how to 'refresh' a JList? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "how to Watch "how to New topic

how to 'refresh' a JList?

Peter Primrose
Ranch Hand

Joined: Sep 10, 2004
Posts: 755
Hi all,

I have a JList:

myJList = new JList(model); //model is a DefaultListModel
myJList.setCellRenderer(new ItemRenderer());

The JList has some items that are painted (COLOR) according to a specific parameters.
The user is able to chagne a value and as a result - the color of the item should be changed accordingly.

1/1/2005 abc 2/1/2005 (this is painted in red)
1/1/2005 bbc 5/1/2005 (this is painted in green)
1/1/2005 fox 7/1/2005 (this is painted in green)

When the user changes it (say he changes the date) - i need to instruct the myJList to change the color - accordingly
I thought


will do it but I guess i was wrong.

any idea?

tito bayuadji

Joined: Apr 18, 2002
Posts: 12
how about repaint()?
I agree. Here's the link:
subject: how to 'refresh' a JList?
Similar Threads
need help with JPanel, liseners, and referencing vectors
programmatic change of text item color in JLIst
set background of JList
Extracting jar file contents to JBOSS tmp directory
How to add a String array to JList?