JCombobox return Customized index

Posted on 2006-04-26
Medium Priority
Last Modified: 2010-03-31
Hi experts :)

What do I really need is a JCombobox but with little customization let me give U the story

I hava an (Area) lookup table in database and it has 2 fields
1 - area_id (index) for example 1,23,20,55,....
2 - Area  (value) for example Faiha,Kaifan ....

let say that I got the the data from database to an array[] ok but how can I fill the JCombobox so the user select the (Value) of area and it returns the (index) !!! which is a (Customized index)

Question by:AL3OMDAH
LVL 92

Expert Comment

ID: 16549247
You can add any class you want to your combo. So you can create a class that includes the value and the index and instances of them to your combo.
You'd them use either a custom renderer or the toString() method of your class to display the value as required.

LVL 30

Accepted Solution

Mayank S earned 400 total points
ID: 16552193

Featured Post

Technology Partners: 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

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses
Course of the Month14 days, 18 hours left to enroll

840 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