Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

JList -> ListModel, adding items

Avatar of rossryan
rossryan asked on
JavaEditors IDEs
1 Comment1 Solution1095 ViewsLast Modified:
Hello All,

Having some trouble with JLists. Here's how it goes.

I have created (visually, with NetBeans) a JList. And I need to update (on demand) the items displayed in the JList. I can't find a way to do this.

Everywhere I look, code says to create a new Jlist, with a listdefaultmodel, and jScollpane. It's not doing anything for me. What I want to do is update an already existing JList (given that it was created visually, I don't think setting the existing JList variable to a new JList is going to do anything, but I tried anyway, and yes, it does nothing).

So, how do I update an already existing JList?

private javax.swing.JList jList_Trips;
private javax.swing.JScrollPane jScrollPane_Trips;

private void RefreshList() {

        DefaultListModel data = new DefaultListModel();
        jList_Trips = new JList(data);
        jScrollPane_Trips = new JScrollPane(jList_Trips);

Avatar of Mick Barry
Mick BarryFlag of Australia imageJava Developer
This problem has been solved!
Unlock 1 Answer and 1 Comment.
See Answers