• Post Reply Bookmark Topic Watch Topic
  • New Topic

JComboBox problem

 
Sivakumar Nachimuthu
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

i want to store the objects in jcombobox.but the display name in combo should be one of it's properties of that objects like name,id etc.
This is same as value and text of select/option in html.
can we do that in java?

Thanks
Siva
 
Sebastiaan Kortleven
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As a default the JComboBox will call the toString method of the objects.. so you could write your own toString method and have it return the value of the variable..
You could also create your own ListCellRenderer...
 
Sivakumar Nachimuthu
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Now,i want to display remote interfaces of EJB in JComboBox.we cant override toString() method in remote interfaces.So is there anyother way other than overriding toString() method.
tell me abt ListCellRender in detail.

Thanks
Siva
 
Don Kiddick
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How to use lists
 
Sivakumar Nachimuthu
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

Thanks for ur help.I have written customized list renderer in which i have modified toString() method to my own remote Interface's getProperty() method.
As iam displaying remote interfaces,for every renderer call,it calls Database to access the value.So is it advisable to list remote interfaces in JComboBox.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!