Solved

Java Swing : Updating screen to show new listbox contents

Posted on 2007-12-02
2
2,252 Views
Last Modified: 2013-11-23
Hi. This is a newbie question.
I have a simple Java program with Swing. An extract:

listData = new Vector();
listData.add("Hello there");
listData.add("hihi");
listbox1 = new JList( listData );
...
midSection.add(listbox1, BorderLayout.CENTER);

This works, and it displays the contents of the vector in the Listbox on the screen just fine.

The problem is when a button is pressed, the listData vector gets modified. How can I make the listbox "update" to show the new contents?

Thanks

Open in new window

0
Comment
Question by:pendulumx
2 Comments
 
LVL 92

Accepted Solution

by:
objects earned 50 total points
Comment Utility
listData = new DefaultListModel();
listData.addElement("Hello there");
listData.addElement("hihi");
listbox1 = new JList( listData );

then add new elemnents to listData
0
 
LVL 1

Author Closing Comment

by:pendulumx
Comment Utility
Yep, that'll do for me. Thanks.
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

In our object-oriented world the class is a minimal unit, a brick for constructing our applications. It is an abstraction and we know well how to use it. In well-designed software we are not usually interested in knowing how objects look in memory. …
Programmer's Notepad is, one of the best free text editing tools available, simply because the developers appear to have second-guessed every weird problem or issue a programmer is likely to run into. One of these problems is selecting and deleti…
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now