Skip to main content

JXComboBox with different autocomplete values for each cell in a JXTable

1 reply [Last post]
bolsover
Offline
Joined: 2005-01-10
Points: 0

Yesterday I had some difficulty getting a JXComboBox with autocomplete working correctly in a JXTable. I eventually got the system working nicely with the following code applied as part of a table column model:

DefaultTableColumnModelExt model            = new DefaultTableColumnModelExt();
...
TableColumnExt col0 = new TableColumnExt(0, 40);
JXComboBox partComboBox = new JXComboBox(PartListData.getPart_nos());
partComboBox.setEditable(true);
AutoCompleteDecorator.decorate(partComboBox);
col0.setCellEditor(new ComboBoxCellEditor(partComboBox));
col0.setTitle("Part No");
model.addColumn(col0);
.. other columns
return model;

In the above code, PartListData.getPart_nos() returns a fixed String[] and the same editor is applied to all cells in column 0 of the table.

My new challenge is to use a JXComboBox as an autocomplete editor for String[] data that is different in every cell in the same column. The question is how?

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
kleopatra
Offline
Joined: 2003-06-11
Points: 0

hmm ... where's the problem?

My first impulse would be to do it the same way as with a standard comboBox as editing component: subclass the editor and update the combo's model in getXXComponent as appropriate.

Cheers
Jeanette