JCombobox return Customized index

Posted on 2006-04-26
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

    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


    Featured Post

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    Join & Write a Comment

    Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
    Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
    Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
    The viewer will learn how to implement Singleton Design Pattern in Java.

    745 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

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now