Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

combobox ,how to get it from Table

 
Arun Sanker
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,

Have a table ,in which Iam rendering a column to display as combobox while editing.
Iam doing it as follows.

// These are the combobox values
String[] values = new String[]{"item1", "item2", "item3"};
JComboBox comboBox = new JComboBox(values);
comboBox.setEditable(true);
sheetColumn.setCellEditor(new DefaultCellEditor(comboBox));

//sheetColumn is a column in my table(1st column).



Which component should I get from the table,to add the keyListener to it & how will I get this component from the table?.


Have added a listener as follows:

X" .addKeyListener(new KeyAdapter(){

public void keyTyped(KeyEvent e){
char c = e.getKeyChar();


})
}

Thanks...
 
Arun Sanker
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It worked when I did

combobox.getEditor().getEditorComponent().addKeyListener(new KeyAdapter()
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic