• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Find a way to hook the tab key in table editors with multiple columns

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
I have a form which has text box, table, buttons as control. The table has 3 columns. The problem here is
1. when the table is active and the cursor is in 1st row and 1st column, if i press tab it must go to next column. Instead of going to the next column, its going to next control.
2. I want SWT table to be work as similar to MSword table.

Kindly give me some suggestions as soon as possible.

Thanks

Regards
Karthick.
 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
The Jtable has a method called changeSelection that will get called if a tab is pressed on any cell. Over ride this appropriately.
 
Kamesh Loganathan
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Another way of doing it is registering the tab key to an action for the table.

Maybe this snippet may help.


Action focusNextRow = new AbstractAction()
{
public void actionPerformed(ActionEvent e)
{
int nextRow = servicesTable.getSelectedRow()+ 1;
if (servicesTable.getSelectedRow() != (servicesTable.getRowCount() - 1))
{
servicesTable.changeSelection(
nextRow,
2,
false,
false);
servicesTable.editCellAt(nextRow, 2);
// Defect : 5859
// Exception Ctrl/Enter used on Ser. to be Est Tab
// User can using ctrl/Enter on the on on-editable cells in
// the table.
// servicesTable.getEditorComponent().requestFocus();
TableCellEditor tableCellEditor = servicesTable.getCellEditor(nextRow,2);
Component component = tableCellEditor.
getTableCellEditorComponent(servicesTable, servicesTable.getValueAt(nextRow,2),
true, nextRow, 2);
}
}
};

servicesTable.getInputMap(1).put( KeyStroke.getKeyStroke
(KeyEvent.VK_ENTER, InputEvent.CTRL_MASK), "focusNextRow");
servicesTable.getActionMap().put("focusNextRow", focusNextRow);
 
reply
    Bookmark Topic Watch Topic
  • New Topic