Skip to main content

JXComboBox with autocomplete as editor in JXTable

3 replies [Last post]
bolsover
Offline
Joined: 2005-01-10
Points: 0

Hi All
Just downloaded 1.6.4 - excellent work!

I'm actually trying to use JXComboBox as an editor with autocomplete within a JXTable.
Can't seem to get it working - are there any examples available?

I'm currently using the following to build the Table column model:

DefaultTableColumnModelExt model = new DefaultTableColumnModelExt();
...
TableColumnExt col0 = new TableColumnExt(0, 40);
JXComboBox partComboBox = new JXComboBox(PartListData.getPart_nos());
//PartListData.getPart_nos() returns String[]
AutoCompleteDecorator.decorate(partComboBox);
col0.setCellEditor(new DefaultCellEditor(partComboBox));
col0.setTitle("Part No");
model.addColumn(col0);
...
With the above, I am able to select items from the partComboBox - but autocomplete does not work.

Any pointers please?

Thanks, David

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
bolsover
Offline
Joined: 2005-01-10
Points: 0

Nevermind...
After hours earlier attempting to find the solution, I just found ComboBoxCellEditor ...

code now reads:

DefaultTableColumnModelExt model = new DefaultTableColumnModelExt();
...
TableColumnExt col0 = new TableColumnExt(0, 40);
JXComboBox partComboBox = new JXComboBox(PartListData.getPart_nos());
//PartListData.getPart_nos() returns String[]
AutoCompleteDecorator.decorate(partComboBox);
col0.setCellEditor(new ComboBoxCellEditor(partComboBox));
col0.setTitle("Part No");
model.addColumn(col0);

and works a treat!!

bolsover
Offline
Joined: 2005-01-10
Points: 0

Finally...
Could I suggest an edit to the JXComboBox api doc - to mention using ComboBoxCellEditor in a Jtable.
Thanks
David

kleopatra
Offline
Joined: 2003-06-11
Points: 0

Glad you finally found what you need :-)

To be honest, I didn't know swingx has a specialized editor. Without really looking, I assume that it's more for supporting the autocomplete feature than anything in the JXComboBox? If so, the doc of autocomplete should be somewhere updated to mention the editor?

Cheers
Jeanette