Help coderanch get a
new server
by contributing to the fundraiser
  • 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
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

Combo box madness

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am trying work a combobox with an array of objects. Im passing the in the combobox constructor but its coming up with what i think is the address of the object within the elements of the array. Is there anyway to get it to printout the local variables within each objects?


here is code:



returnplayers() returns an array of player objects. I just want to displaye their names instead of "Domain.Player@2f729e" which is what i am getting atm in the combobox.


thanks
 
Marshal
Posts: 28288
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What you are seeing there is the result of calling the toString() method of the Player object. Since you haven't provided an implementation of that method, you get the default implementation provided by the Object class.

So implement a toString() method in your Player class and have it return whatever you want to see in that combo box.
 
Ramzi Hajaj
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That is sick! Cheers man will sort this madness out.
 
Marshal
Posts: 79635
380
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Careful what you write. There are people all over the world here, and many will misunderstand things like “That is sick!” and madness.
reply
    Bookmark Topic Watch Topic
  • New Topic