I need to fill a JComboBox with a list of String items, which are quite long. Now, when the combo box width is shorter than items' size, if I use "regular text" strings
there are no problem: item's text is truncated with ellipses.Instead, if I use "html strings" (I use html to get different colours in displaying items), JComboBox tries
and wraps line..
I'm just wondering if a method exists to achieve truncation even with HTML.
I insert items which are couples <code, description>, read from database.
Usually in this case the "code" is not displayed in the combo box since the user generally doesn't care about the code value that is used to access data in the database. So the user would only see the "description". Then when you program gets the selected Item it can access the code value for further processing.
However, if you really want to display both values then here are a couple of other options for displaying a multi column combo box that might help:
Joined: Jun 24, 2005
Thank you A LOT for your reply... anyway, i don't want a multi line combo box. I just want to make the combo truncate the description if it's too long to be displayed...
Anyway your code is very precious for me. I'll study it to get advice.