Hi all

We have to create a program that will require a lot of database interaction.

I would like to create a JList with all events where a user can select an event he would like to edit.
Is there a good way to store ID's into the list and retrieve them easily? Without having to put the ID into the displayed text and then fooling around with substring etc...

Thanks in advance
Greetings, Kenny

8 Years
Discussion Span
Last Post by K?!

You could create a little class to hold the event description and the database ID (and maybe any other relevant stuff). You can add those class members to the JList, and it will display them by calling their toString() method, so define a toString() that just returns the event description. When you query the selected item, you'll get the whole object (not just the displyed string), so you can retrieve its ID directly from it


Great, didn't know that was possible :)
Thanks, that's really a great help :)

Greets, Kenny.



I have one more question.
I know I could test this, but we're still designing, and there's little time, so if anyone who already knows could just tell me that would come in quite handy.

Is it possible to do this (what I asked before) with a dropdown list too? I bet the answer is yes, but I wanted to make sure.

Tanks in advance
Greets, Kenny

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.