Solved

Java Swing : Updating screen to show new listbox contents

Posted on 2007-12-02
2
2,266 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.

733 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