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

Discussion in 'Java' started by umer, May 4, 2005.

  1. umer

    umer Guest

    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 !!
    umer, May 4, 2005
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Michal M
    Replies:
    7
    Views:
    775
    Andrew Thompson
    Aug 2, 2005
  2. Replies:
    3
    Views:
    5,140
    Bjorn Abelli
    Mar 30, 2006
  3. manzur
    Replies:
    5
    Views:
    484
    Chris Uppal
    Nov 9, 2006
  4. Replies:
    0
    Views:
    708
  5. Mark Rafn
    Replies:
    17
    Views:
    1,362
    Andreas Leitgeb
    Jul 5, 2009
Loading...

Share This Page