How Do I Refresh Components in a Java Swing GUI?

I have a JList that is defined as

private final JList _list = new JList(getList());

where getList() returns a String array.

I can change the String array elsewhere in the GUI so how can I have the JList refresh with the new options everytime I make a change? Is there some sort of


function that I could call?

I also have the same problem with a JTextArea defined as

private final JTextArea _textArea = new JTextArea(getMessage());

where getMessage() returns a string. How can I have them refresh?

Hi dominique,

Since I don’t “swing”, I can’t tell you. But perhaps the moderators will move this to the proper forum.

mods: (java != javascript)


Originally posted by Vincent Puglia
mods: (java != javascript)
Of course not, but it’s nonetheless still client side coding. I’m not talking about Java Server Pages. We don’t have a Java/C/C++/C#/Fortran/Cobol/etc. forum so this one is as close as you get.

Swing components don’t have a refresh method because of the way they are built and work.

try this


I’m a bit rusty on the old java&swing