28 Mar 09 2:25
How can i customize only the first row to JComboBox in jTable? (Only one row in the JTable, not the whole column)
I tried using the following code:
EachRowEditor rEditor = new EachRowEditor(bti.BTIC.comboBox,false,bti.BTIC);
Here the whole column(0) was set to comboBox. When executed, when i click on any cell of column(0), the comboBox is displayed. That is, when the user clicks in a cell of the first column, the drop down list of comboBox is appearing. This behaviour is correct.
But I only need the whole row(0) to be set to JComboBox in JTable. So I tried using the following code:
for (int n=1;n<bti.BTIC.columns.length ; n++)
EachRowEditor rowEditor = new EachRowEditor(false,bti.BTIC);
rowEditor.add(0, new DefaultCellEditor(new JComboBox(bti.comboBox.getModel())));
where JTable and JComboBox are defined/implemented under bti.BTIC.
Here i was able to achieve in setting the whole row(0) to comboBox. When executed, when i clicked on any cell of row(0), immediately, i'm not able to display the comboBox. The user has to click on that cell, type something to get the drop-down list of comboBox, OR double click on that cell to get the drop-down list.
My question is to get the drop-down list of comboBox when the user once clicks on the cell of a JTable row which is customized to JComboBox.
Any help would be appreciated.