-
database results in drop-down
I think I understand how to display 1 value (i.e. "integra") in a drop down menu.
What I'm stumped about is... how would I display multiple data on one line in a drop down list?
for example... my database will return, last name, first name, phone# on one line of my JList.
I would be using a JList with the following options:
-setVisibleRowCount(1)
-setSelectionModeListSelectionModel.SINGLE_SELECTION);
I assume JList IS the thing to use in this case...
P.S. Please keep in mind that from the example above, the items to be placed in one line of the JList may be from different tables
-
Gun,
Following your example, I'm assuming you are getting the last name, first name, phone# values all in a result set from your database. If your question is the "how" of joining tables and getting values from them, you'll have to address that before trying to display them.
As far as displaying multiple attributes in each row, I think you can get what you're describing by gathering your result data, concatinate them into Strings, build a List of the Strings, then put that List into the JList.
So using your example and assuming you loop through the values from your database and assign them to lastName, firstName, and phone:
-------------------------------------------------------------------
Vector displayVector = new Vector();
String displayString = null;
// start loop
// assign values to lastName, firstName, phone
displayString = (lastName + ", " + firstName + " " + phone); // build String
displayVector.addElement(displayString); // add String to Vector
// end loop
JList myJList = new JList(displayVector); // load JList with Vector
-------------------------------------------------------------------
I haven't dealt with Swing in a while, just working off the API. Hope this helps some.
-- Steven
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks