• Post Reply Bookmark Topic Watch Topic
  • New Topic

ComboBox Id  RSS feed

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

I have rendered a column of my table with a combobox.Some questions surfaced when I worked deep in to it.

I have rendered the cell which would look like a combobox only on editing as follows.

Have something as follows in my code.Its not sequential

private JTable table = null;
private JComboBox comboBox=null; //// [1]

setUpSheetRangeColumn(table, table.getColumnModel().getColumn(1));

public void setUpSheetRangeColumn(JTable table,TableColumn sheetColumn){

String[] values = new String[]{"ixyz", "defg", "iabc"};
comboBox = new JComboBox(values);
sheetColumn.setCellEditor(new DefaultCellEditor(comboBox));


Have a function in my class,as below,where Iam passing the combo and want to trap the keypress events on the combo.

public void addKeyListener(final JComboBox test){

Component comp1;
comp1 = test.getEditor().getEditorComponent(); //[2]

So for example if I have a "KeyPressed" event handler as follows:

public void keyPressed(KeyEvent e){



My questions are :

In [1](see comment where "[1]" is indicated),where Iam creating the comboBox, the id is, say "48" &

From "comp1","getSource" & "getComponent" ,the id is say "50"

Why are the id's different. Thought that the id's should be the same as they are referring the same component.

  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!