Re: Controlling JComboBox size in JTable cell
- From: Vova Reznik <byRequest@xxxxxxxxxxxx>
- Date: Mon, 27 Jun 2005 20:14:20 GMT
Yulia wrote:
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
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;
}
.- References:
- Controlling JComboBox size in JTable cell
- From: Yulia
- Controlling JComboBox size in JTable cell
- Prev by Date: Re: automatically maximize JTable?
- Next by Date: Re: JTables
- Previous by thread: Re: Controlling JComboBox size in JTable cell
- Next by thread: JSpinner ChangeEvent and JOptionPane
- Index(es):