File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes Multi colored JComboBox Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Multi colored JComboBox" Watch "Multi colored JComboBox" New topic
Author

Multi colored JComboBox

Sajee Joseph
Ranch Hand

Joined: Jan 17, 2001
Posts: 200
Hi,
I need to have a JComboBox which contains a list of names.. say
"Joe", "saj", "sanjay", "ajai".... so on. Now depending on some condition i need these names to appear either in Red or in Blue.
I know that i can have my own class
MyCellRenderer which extends JLabel implements ListCellRenderer
and i can set this as the renderer for my JComboBox.
But my requirement doesnt end with this. When i made my own rendered i noticed that though the names in the dropdown list appeared in the color i wanted, yet the name that appears next to the "arrow" button is in Black. Also when i didnt have a renderer, the drop down list would automatically listen to the keys. For example if i type 's', the focus would automatically go to the first item that starts with 's'. However when i use my renderer, this doesnt happen. Help me solve these 2 problems .
Kindest regards
Saj
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Multi colored JComboBox