Link to home
Start Free TrialLog in
Avatar of mfAudi
mfAudi

asked on

Adding ID to JComboBox

Hello there,

I´ve got a problem with the JComboBox! I get a List of items, which I add to a JComboBox but I´m only able to add the "TEXT" to it. But I also have to add a ID, which identifies the Text, to the ComboBox. Do you have any Solution for my problem??

Thanks a lot for your help!

Greetings
Markus
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

The ComboBoxModel holds Object. You can make an object with those fields. Make its toString retrun what you want and it#'ll be displayed
Avatar of mfAudi
mfAudi

ASKER

Can you show me a little Example??

THX
ASKER CERTIFIED SOLUTION
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
mfAudi can you tell me why my answers were ignored?
This should have been a split.
Avatar of mfAudi

ASKER

I don´t know! I accepted your last answer! And I also rated it as "GOOD"!

Why are you asking??

You accepted my answer, not CEHJ's.
>>I accepted your last answer!

No you didn't - you accepted *someone else's* answer ;-)
Avatar of mfAudi

ASKER

I´m sorry, so did I! But both answers were similar in quality!

Sorry CEHJ! Next time. I was to much in a hurry cause I have to solve a problem at my workingplace!

Have a nice WE!

CU
>>But both answers were similar in quality!

I have to beg to differ and that's no disrespect to mayank. His link, while useful, does not deal directly with your specific problem
Ah, so CEHJ takes the name finally in his 9 years at EE ;-)

mfAudi, if the sample code on the link which I posted helped you and if that was the one you used, then you should split the points between CEHJ and me because he had also posted a similar code earlier.

I'll ask Venabili to re-open.
:-)
Avatar of mfAudi

ASKER

OK, no Problem! Both of you helped me very much!

But no I finisch working and I will do it on monday!

Hasta la vista!

Greetings from good old Germany! (SOCCER-World-Championship-2006) ;-)
>> Both of you helped me very much!

mfAudi, you can now follow the Split Points link which you see below (and above the comment box) to split points between CEHJ and me.
> Greetings from good old Germany! (SOCCER-World-Championship-2006) ;-)

Go the socceroos :)
:-)