problem dispatching a key event in the new release i.e jdk1.5

U

umer

Hi this is my first post in this group, i just became a member.
The problem i'm having is, that i'm trying to dispatch a key event to a

textField that is a cell editor in a JTable, these things will make
more sense when i put my code snippet in the end. Anyways I generate a
key event and then dispatch it to the control i want to, and i've added

a keyListener to that control to track the events invoked, if i hit the

keys on the keyboard it shows me the debug message that <this> key was
pressed and so on. And it used to work fine on 1.4.2_04/05/07
any of the 1.4 release, but as soon as i downloaded and installed the
new release 1.5 it stopped workin'. If anybody can help me with this
its highly appreciated.


here's a snippet from my code where i'm generating a key event and
dispatching it.


//////////////////////////////­///////////////////////


int selRowNum = gbTable.getSelectedRow();
int selColNum = gbTable.getSelectedColumn();
if( selRowNum != - 1 && selColNum != - 1 )
{
DefaultCellEditor dce = (DefaultCellEditor)
gbTable.getCellEditor( selRowNum, selColNum );


if( e.getKeyCode() == KeyEvent.VK_TAB || e.getKeyCode() ==
KeyEvent.VK_UP || e.getKeyCode() == KeyEvent.VK_DOWN || e.getKeyCode()
== KeyEvent.VK_LEFT
|| e.getKeyCode() == KeyEvent.VK_RIGHT )
{
KeyEvent e1 = new KeyEvent( dce.getComponent(),
KeyEvent.KEY_PRESSED, System.currentTimeMillis(), 0, KeyEvent.VK_A, 'A'

);
dce.getComponent().dispatchEve­nt( e1 );


//////////////////////////////­//////////////////////////////­/


hope this makes sense
lemme know if u need any more info
again Thanx for your help !!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top