• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

JComboBox problem

 
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How to use lists
 
Sivakumar Nachimuthu
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic