Hi,
I have a JTable where each cell is huge (in purpose).
One of the columns uses DefaultCellEditor with JComboBox (so when user
edits value of this column, a combo-box is displayed).
The problem is that this combo-box is stretched and gets huge
arrow-button (with height similar to its containing cell).
How can I make the combo-box smaller, so its height will be smaller
than the height of the cell that contains it?
Thanks in advance,
Yulia
Christian Kaufhold - 27 Jun 2005 20:54 GMT
> I have a JTable where each cell is huge (in purpose).
> One of the columns uses DefaultCellEditor with JComboBox (so when user
[quoted text clipped - 4 lines]
> How can I make the combo-box smaller, so its height will be smaller
> than the height of the cell that contains it?
Use (e.g.) JPanel with JComboBox as child as editor.
Please don't multipost.
Christian
Vova Reznik - 27 Jun 2005 21:14 GMT
> Hi,
>
[quoted text clipped - 10 lines]
>
> Yulia
Method of JTable
public Component prepareEditor(TableCellEditor editor, int r, int c)
returns your combobox. You can override it and return JPanle with combobox
something like this:
public Component prepareEditor(TableCellEditor editor, int r, int c) {
Component comp = super.prepareEditor(editor, r, c);
editorPanel.removeAll();
// editorPanel is JPanel defined as private class variable
// size of your combobox should be its preferred size
editorPanel.add(comp);
return editorPanel;
}