assign keys for combo box in java

Posted by adesh kumar on Stack Overflow See other posts from Stack Overflow or by adesh kumar
Published on 2012-10-13T07:08:02Z Indexed on 2012/10/13 9:37 UTC
Read the original article Hit count: 240

Filed under:
|
|
|

I want to add a JComboBox in Swing that is simple but I want to assign the values for each items in combo. I have the following code

    JComboBox jc1= new JComboBox();
    jc1.addItem("a");
    jc1.addItem("b");
    jc1.addItem("c");

Now what I want is that when click on combo box it should return 1, 2 and 3 correspondingly instead of a ,b, c. Is there any way to assign the key values for each items in combo box?

© Stack Overflow or respective owner

Related posts about java

Related posts about swing