[Bluej-discuss] Enter in JTable
Michael Kölling
M.Kolling at kent.ac.uk
Wed Jul 12 14:08:50 BST 2006
Hi Beat,
Maybe you should try to use keyTyped, instead of keyPressed.
When a key is pressed, three events are generated in the sequence:
keyPressed
keyReleased
keyTyped
The keyTyped event is generated when the whole deal is complete.
Using this, your code may run after the built-in code, and thus get
final say in where to put the focus.
It may not be sufficient, but it's probably worth doing.
The second thing to do is to call the isConsumed() method of the key
event. This signals to the rest of the event system that you have
dealt with this event, and that the default framework should not do
anything further with this event.
Regards,
Michael
On 12 Jul 2006, at 11:46, Beat von Arx wrote:
> Hello!
>
> I want to use the keyPressed event in a JTable to process some data
> and then select a specific table cell to guide the user for his
> next entry. I try to use editCellAt(row,col). If I use this method
> within a keyPressed event handler when the key was Enter or Tab, I
> can set the editing cell, I can even print it to verify the correct
> cell, but as soon as the keyPressed method is left, it seems, that
> some "higher force" handles the Enter key also and positions it
> according to its own rules. How can I avoid this and select the cell
> where I want it?
>
> (I have no problem to set the editing cell if I do it from outside
> of a keyPressed handler.)
>
> --
>
> Thank you!
> Beat
>
> using XPhome, BlueJ 2.0.4, J2SDK 1.4.2_06
>
> _______________________________________________
> mailing list bluej-discuss at bluej.org
> To unsubscribe or change your preferences, go to
> http://lists.bluej.org/mailman/listinfo/bluej-discuss
More information about the bluej-discuss
mailing list