Working with Combo boxes in JTable in swings

Advertisement
Hello everyone,
I am working on swing components. We are designing a swing based platform for our company. I have a case where i have to use comboboxes in a jtable. I have seen a lot of topics on this but i have an issue with that. We have to implement a type ahead feature in these comboboxes where if we type any key the items in the table which start with that alphabet or sybol are selected. We can see this by default in regular comboboxes but i have been unable to implement this in the jtable. I have tried various ways like adding listeners etc. and none of them are working. This is my code for the cell renderers for these comboboxes
public class MyComboBoxRenderer extends JComboBox implements TableCellRenderer {
public MyComboBoxRenderer(Vector items) {
super(items);
public Component getTableCellRendererComponent(JTable table, Object value,
boolean isSelected, boolean hasFocus, int row, int column) {
if (isSelected) {
setForeground(table.getSelectionForeground());
super.setBackground(table.getSelectionBackground());
} else {
setForeground(table.getForeground());
setBackground(table.getBackground());
setSelectedItem(value);
return this;
public class MyComboBoxEditor extends DefaultCellEditor {
public MyComboBoxEditor(Vector items) {
super(new JComboBox(items));
Can anyone who has faced a similar issue help me regarding this.
Thanks in advance
Edited by: bharat20 on Nov 14, 2007 6:58 AM
Advertisement

Replay

Hi,
Have you tried the Swing forums at java.sun.com? This is the Java Studio Enterprise IDE Forum, so you probably won't get much response here.
http://forum.java.sun.com/category.jspa?categoryID=7
Also, what IDE tools are you using?
R