mfAudi
asked on
Getting Object and Objectinformations selected in Combobox
Hello there,
once again a problem with java! I´ve got an ComboBox which is filled with objects (Object type is my own)! I can select them but can´t get the objectinformations. Can anybody show me how to handle this??
THX
mfAudi
once again a problem with java! I´ve got an ComboBox which is filled with objects (Object type is my own)! I can select them but can´t get the objectinformations. Can anybody show me how to handle this??
THX
mfAudi
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
:-)
ASKER
CEHJ
THX for your help! Somtimes my brain is some kind of blocked! My thougths are just to complicated!
Just one question: Where do you come from??
THX for your help! Somtimes my brain is some kind of blocked! My thougths are just to complicated!
Just one question: Where do you come from??
>>Just one question: Where do you come from??
Originally from Manchester UK, but living in London and Somerset
Originally from Manchester UK, but living in London and Somerset
yopu can use a renderer to hadle how your object is displayed
You can cast (as shgown above), and use instanceof to check the type of the value
eg.
Object selected = combo.getSelectedItem();
if (selected instanceof MyBean)
{
MyBean bean = (MyBean) selected;
String property = bean.getProperty();
// ...
}
where MyBean is obne of your classes that you are stoing in the combo
you'll find lots of goo info on usoing combos here:
http://java.sun.com/docs/books/tutorial/uiswing/components/combobox.html