GeeCON Prague 2014*
The moose likes Swing / AWT / SWT and the fly likes JCOMBO Box traversal problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JCOMBO Box traversal problem" Watch "JCOMBO Box traversal problem" New topic
Author

JCOMBO Box traversal problem

ashok rajendran
Greenhorn

Joined: Mar 31, 2008
Posts: 5
I have a JTable with 3 columns. The columns are radio button, jlabel and Jcombo Box. Each of them are retrieved using renderer. The first two columns are generated using super.getRendererComponent method. The combo box for last column is generated explicitly in the getRendererComponent method of DefaultCellRendererImpl class.

I give a simple layout of the program i have here.

// renderer for the 1st column of my table. It extends DefaultTableCellRenderer. We create a JRadiobutton in the getTableCellRendererComponent() method and return that component. So this column will be showed as radio button
final TableCellRenderer Col1Renderer = new RadioBtnTableCellRenderer();

//renderer for 2nd and 3rd column. It extends DefaultTableCellRenderer. In the getTableCellRendererComponent() method, we call super.getTableCellRendererComponent() method if it is 2nd column (It displays like a label) and we create a JcomboBox and return the component if it is a 3rd column.
final TableCellRenderer nameValRenderer = new NameValueCellRenderer();

// This model is returning values for each column appropriately
//Here column 0(1st) and 2(3rd) is marked as editable
CustLayersTableModel tm = new CustLayersTableModel();

// Set-up the JTable with custom renderers
custLayersTable = new JTable(tm)
{
// Override the cell render to show the layers name, value
// after tip layer as disabled
public TableCellRenderer getCellRenderer(int row, int column)
{
if ( column == LAYER_VAL_COL ||
column == LAYER_NAME_COL)
{
return nameValRenderer;
}
else if ( column == TIP_LAYER_COL )
{
return tipRenderer;
}

return super.getCellRenderer(row, column);
}
};

TableColumnModel colModel = custLayersTable.getColumnModel();

//The 1st column is configured with cellEditor class TipLayerCellEditor. This class extends AbstractCellEditor and implements TableCellEditor. In the getTableCellEditorComponent method we are creating a radiobutton with the values and returning the component.
TableColumn tipCol = colModel.getColumn(0);
tipCol.setCellEditor(new TipLayerCellEditor());

//The 3nd column is configured with cellEditor class LayerValueCellEditor. This class extends AbstractCellEditor and implements TableCellEditor. In the getTableCellEditorComponent method we are creating a comboBox with some values and returning the component.
TableColumn valCol = colModel.getColumn(2);
valCol.setCellEditor(new LayerValueCellEditor(this));

This code is working fine. We are able to edit the comboBox by clicking on that comboBox. When we do tab from other cells the focus is not coming to the combo Box to edit. Even after clicking the comboBox we can select the values only through mouse not by keyboard.

Please help me to bring the focus to the combo box of the third column
 
GeeCON Prague 2014
 
subject: JCOMBO Box traversal problem