Click to See Complete Forum and Search --> : How can I set focus to a particular table's cell


Proverbs9_10
February 23rd, 2000, 02:28 AM
How can I set focus to a particular table's cell?

Thanks

Ting Chen
February 23rd, 2000, 04:39 AM
Hello,

you can select a cell in a table, and you can edit that cell. If you edit that cell, the celleditor of it get the focus and the table lost the focus. If you just select the cell, the table has the focus but the cell is selected.

You can select cells with the following methods:

setColumnselectionInterval(int, int)
setRowSelectionInterval(int, int)



and you can edit a cell by the following method:

editCellAt(int iColumn, int iRow)




Greetings
Ting.

Proverbs9_10
February 24th, 2000, 12:46 AM
Thanks for your reply! It works.

How can I cancel the focus of a particular cell?
Suppose that when user click a particular cell, I will show
a dialog.
After that, I want to cancel the focus of this cell.
How can I achieve it?

Ting Chen
February 24th, 2000, 05:53 AM
Hello,

to cancel the selection, use the methode

JTable.clearSelection();




To cancel the editing, use the methode

JTable.getCellEditor().stopCellEditing();




Greetings.
Ting.

Proverbs9_10
February 25th, 2000, 06:13 AM
Thanks a lot!
It works