Board index » jbuilder » How do I prevent user to navigate in a JdbTable, except for within a row?

How do I prevent user to navigate in a JdbTable, except for within a row?


2003-12-18 07:17:44 PM
jbuilder7
In a jdbTable I want the user to be able to navigate, and perhaps edit
cells, on a specific row only. I do no want him to move to another row
through the keyboard (nevermind the mouse).
The Tab, Down and a few other keys do move the focus out from the row. I
simply want the jdbTable to ignore these keystrokes. A keyboard Listener
will not help me since the row will anyway change. Adding a key to an
ActionMap will have the same effect I believe.
If I subclass jdbTable, is there a way to override some operation to
accomplish what I want? In that case what operation?
Örjan Leringe
 
 

Re:How do I prevent user to navigate in a JdbTable, except for within a row?

I finally found a solution. It uses InputMap and ActionMap. In case anyone
is interested: Here it is for the case of "Enter" as an example:
myMap = jdbTableX.getInputMap();
Action FixEnter = new AbstractAction() {
public void actionPerformed(ActionEvent e) {
int nrOfCols = jdbTableX.getColumnCount();
int theCol = jdbTableX.getSelectedColumn() + 1;
if (theCol < nrOfCols) { // move in any case if not last column
jdbTableX.setColumnSelectionInterval(theCol,theCol);
}
}
};
myMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0),"FixEnter");
jdbTableVtfdetaljer.getActionMap().put("FixEnter", FixEnter);
"Örjan Leringe" < XXXX@XXXXX.COM >skrev i meddelandet
Quote
In a jdbTable I want the user to be able to navigate, and perhaps edit
cells, on a specific row only. I do no want him to move to another row
through the keyboard (nevermind the mouse).

The Tab, Down and a few other keys do move the focus out from the row. I
simply want the jdbTable to ignore these keystrokes. A keyboard Listener
will not help me since the row will anyway change. Adding a key to an
ActionMap will have the same effect I believe.

If I subclass jdbTable, is there a way to override some operation to
accomplish what I want? In that case what operation?

Örjan Leringe