Solved

Java Swing : Updating screen to show new listbox contents

Posted on 2007-12-02
2
2,263 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
ID: 20392560
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
ID: 31412212
Yep, that'll do for me. Thanks.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
eclipse giving error when test program exits 6 145
What is an NDK ? 3 103
Object Data Source 4 134
How to format date and time in Eclipse IDE comments 2 83
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. …
How to install Selenium IDE and loops for quick automated testing. Get Selenium IDE from http://seleniumhq.org Go to that link and select download selenium in the right hand columnThat will then direct you to their download page.From that page s…
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.

860 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