aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes searcheable jcombobox custom renderer Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "searcheable jcombobox custom renderer" Watch "searcheable jcombobox custom renderer" New topic
Author

searcheable jcombobox custom renderer

Lucas Smith
Ranch Hand

Joined: Apr 20, 2009
Posts: 804
    
    1

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!


SCJP6, SCWCD5, OCE:EJBD6.
BLOG: http://leakfromjavaheap.blogspot.com
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18659
    
    8

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:
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: searcheable jcombobox custom renderer