?
Solved

Java Swing : Updating screen to show new listbox contents

Posted on 2007-12-02
2
Medium Priority
?
2,281 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 200 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

Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
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 column That will then direct you to their download page. From that p…
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.
Suggested Courses
Course of the Month10 days, 21 hours left to enroll

770 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