Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

searcheable jcombobox custom renderer

 
Lucas Smith
Ranch Hand
Posts: 808
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have the following code:


Everything is fine but I want to gain possibility to search through the combo box. Now, the searching is possible but it uses toString() from Man class. I want to get the right object when I type "test". Overriding toString() in Man is impossible because in the real project it is complicated class. Moreover model should be independent from renderer.
To sum up:
I want to search through combo box with my custom renderer. Searching should match the labels which the user can see and then return the object which lies behind the label
Does anyone have any idea?


I really appreciate any help!
 
Paul Clapham
Sheriff
Posts: 21126
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Lucas Smith wrote:Everything is fine but I want to gain possibility to search through the combo box. Now, the searching is possible but it uses toString() from Man class. I want to get the right object when I type "test". Overriding toString() in Man is impossible because in the real project it is complicated class.


I would write a wrapper class for the Man object which had a suitable toString() method. Example:
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic