Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

SetEditable is not working with combobox

 
prashant gour
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am working with table and using combo box in cell of table in certain condition I have to make combo as editable and non editable.

I have written class which extends DefaultCellEditor

@Override
public Component getTableCellEditorComponent(JTable table, Object value, boolean flag, int row, int column)
{
comboBox.getModel()).setSelectedItem(value.toString());
comboBox.setEditable(true);
}

if i set comboBox.setEditable(true). cell become editable but not able to select any item from combo that value is not come in cell.

but when i do set comboBox.setEditable(false) cell become non editable but now i can select value from combo.

i want both the operations. Editable cell and able to pick value from combo.

Any Idea???

Prashant Gour
 
Gopinath Mani
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hai,

You need to set that particular cell as a non editable one, that is cell in which you had added the combobox.

rgds,
gopinath
 
prashant gour
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
actully i want to select item from combo and to enter value in cell. but that is not working.
any other suggestions. please let me know.

Prashant Gour
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by prashant gour:
if i set comboBox.setEditable(true). cell become editable but not able to select any item from combo that value is not come in cell.


That sounds strange, although it wouldn't at all surprise me if this was a bug in Swing - wouldn't be the only one regarding JTables... :sigh:

I'd search in the sun bug parade for this, if I were you.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic