?
Solved

JCombobox return Customized index

Posted on 2006-04-26
2
Medium Priority
?
225 Views
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)

thanx
0
Comment
Question by:AL3OMDAH
2 Comments
 
LVL 92

Expert Comment

by:objects
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.

http://java.sun.com/docs/books/tutorial/uiswing/components/combobox.html#renderer
0
 
LVL 30

Accepted Solution

by:
Mayank S earned 400 total points
ID: 16552193
0

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