Link to home
Start Free TrialLog in
Avatar of mfAudi
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
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
what information would you like exactly?

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
:-)
Avatar of mfAudi
mfAudi

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??

>>Just one question: Where do you come from??

Originally from Manchester UK, but living in London and Somerset