I'm developing an application that uses a JComboBox rendered in a column of a JTable. I've been getting feedback from users that it wasn't obvious that the particular column was a combo box. When the table is first displayed the text in this column just looks like normal text entered into the cell. It's not until the user actually clicks on the cell does it become apperant that it's a combo box and they can make a different selection. The normal "triangle" to the right of the combobox text is not being displayed that would normally indicate a combo box.
What's the best way to indicate to the users visually that a cell is a combobox and allows selection?
Also use a JCombobox as the cell renderer, not only as the editor.
But make sure that those are two different instances, otherwise you will see some strange behaviour...
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
So I'm setting both the renderer and editor as a JComboBox. Have I setup the renderer correctly? Functionally, everything works fine as is. I can click on the cell and a combobox appears with the two values (AM/PM). It's just when the table is fist displayed you can't tell that the time period column contains comboboxes to select either AM or PM.
The question is this: What's the best way to indicate visually to the user that a cell's value can be changed using the JComboBox? Some I've talked to have suggested using a column header icon or maybe changing the color of the column.
As an example:
Figure 1: No combo box indicator is displayed (unable to visually tell that the "Time Period" column is selectable using a combo box)
Figure 2: Combo box displayed when user clicks on the cell
[ March 23, 2006: Message edited by: David Irwin ]
[ March 23, 2006: Message edited by: David Irwin ] [ March 23, 2006: Message edited by: David Irwin ]
Yes, other than set the cell editor to be a combo box, you need to set the cell renderer (view -- when/where users can see). Here is a custom one that you can set for the "time period" column:
ps. To be just on the safe side, to prevent MyTableCellRenderer (now a JComboBox) to get too many items added, do "removeAllItems()" before "addItem(value)". If the our renderer was a Label, text field, there is no such worry.
[ March 23, 2006: Message edited by: Ben Zung ] [ March 23, 2006: Message edited by: Ben Zung ]
You're not going crazy. You're going sane in a crazy word. Find comfort in this tiny ad:
SKIP - a book about connecting industrious people with elderly land owners