Links

Lists

Latest Updates

Ruby On Rails List
Python list
Advanced Java
The JavaScript List
Apache Users
Full Disclosure
Linux Security

Search the archives!


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Dispatching Events


  • From: cvandeso@xxxxxxxx (cvandeso@xxxxxxxx)
  • Subject: Dispatching Events
  • Date: Mon, 30 Aug 1999 16:14:17 +0200




Hi Rama,

I would suggest this way to propagate a keyevent (method
processKeyEvent(...) of JTextComponent ) :

    KeyEvent tabEvent = new KeyEvent( (Component) this,
                                      KeyEvent.KEY_PRESSED,
                                      System.currentTimeMillis(),
                                      0,
                                      KeyEvent.VK_TAB,
                                      KeyEvent.CHAR_UNDEFINED );
    super.processKeyEvent(tabEvent); //doesn't work with
processComponentKeyEvent();

Regards,
Carlo.

PS. This example is a bad one because it's going to simulate a tab-key,
and in JFC you should use :
FocusManager.getCurrentManager().focusNextComponent(this);, but I had it
laying around, so ...





G Ramasubramani <grsmani@xxxxxxxxxxxxxxxx> on 30/08/99 15:37:13

To:   advanced-java@xxxxxxxxxxxxxxxx
cc:    (bcc: Carlo Van de Sompel/ISD/Anhyp/BE)
Subject:  Dispatching Events




Hi folks,
    Say I have a JTextArea and want to generate a
particular KeyPressed Event. Is it enough if a
construct a new KeyEvent and then call
JTextArea.dispatchEvent(KeyEvent)?
    Are there any more steps to be executed?
Thanks and regards,
Rama