473,325 Members | 2,342 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

Swing JList displaying arraylist

hi,

I have an arrayList in my program that I want to display in a Jlist. I need the JList to update his contents when the elements in the arraylist change/ an element is added/deleted/...

I'm lost on how to do this. Passing the arrayList as an array into the Jlistconstructor will just display the elements, but no updates will be made according to the API.

Apparently ListDataListeners should be used, and I don't seem to be able to find a nice simple tutorial on how to create these things.

Any help is appreciated. Thanks!
Oct 22 '09 #1
2 6265
I thought I should provide some more info.

I have a program on which I have to build a GUI. I may not change anything inside the program. I can get the arrayList to display using a public inspector from the program and this is the only thing I can use to hook it up to a JList.

I have no clue on how to do this in an easy way. I've googled around, finding info on listeners, events, but I don't see a clear solution.
Oct 22 '09 #2
Implementing my own version of ListModel holding an Arraylist did the trick.
Oct 22 '09 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Roman Thurnherr | last post by:
Hi all I'm using two JLists with the same MouseListener in a JFrame. How can I find out on which JList the MouseEvent was released? Is it generally possible or should I use a MouseListener for...
2
by: Fieldmedic | last post by:
I'm attempting to get an arraylist to display in a Listbox (listbox2). The arraylist is created from selections in a different listbox (listbox1). The 1st listbox has a selection mode of...
1
by: Salha | last post by:
Hello there, Can you help me in following problem: Am working on a chemistry dictionary. I want to have all the chemistry terms in a JList and whenever i select a term from a JList, it displays...
0
by: paoparaopao | last post by:
Hi, I want to drag rows up/down in a JList; for example, drag 3rd row to 1st row. I have setDragEnabled(true) for JList, but it doesn't work! How do I drag rows in JList? Thanks!
4
Nepomuk
by: Nepomuk | last post by:
Hi! I'm trying to use a JList. Here's the code: String languages = { "deutsch", // german "english", // english "castellano", // castilian "français", //...
8
by: sukatoa | last post by:
I came from List in awt.... Im currently having an experiment about JList.... say like 140,280 ( h,w ) i have 4 values that have been set on JList using addElement from...
2
by: wishbone34 | last post by:
Hi, here is some of my code public class ControlIL extends JFrame implements ActionListener, ListSelectionListener { private JList Items; //builds the UI public ControlIL(){ ...
8
by: vaskarbasak | last post by:
Hi, I'm having problems displaying Chinese and Japanese characters on Swing components. I know some conversion should be done. Do you have some source code sample or any idea ? Thanks! vaskar
2
by: Gangreen | last post by:
Hi all, I've bumped into an odd problem creating a GUI in swing. As you will see in the screenshots, I have a tabbed layout. Each tab is a Jpanel. On this panel I have put a JList, containing a...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.