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().dispatchEvent( e1 );
/////////////////////////////////////////////////////////////
hope this makes sense
lemme know if u need any more info
again Thanx for your help !!
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().dispatchEvent( e1 );
/////////////////////////////////////////////////////////////
hope this makes sense
lemme know if u need any more info
again Thanx for your help !!