Hi Eyad,

These sort of questions are best answered in the user mailing list (us...@netbeans.incubator.apache.org). I've sent your email there, please respond in that list.

Java has something called the "AWT Event Thread", which is an internal thread that is automatically started by Java for you.

When you click a button, or move the mouse, this "AWT Event Thread" (internal to Java) creates some Java objects called "Events" which contain information about what was clicked, or which is the position of the mouse in the screen.

So the answer to your question is "The Event objects are created for you by the Java AWT Event Thread", and "The Event objects are sent to the listeners you specify.

For more information about events see "Writing Event Listeners" at https://docs.oracle.com/javase/tutorial/uiswing/events/index.html

Hope this helps,
Antonio


El 23/11/17 a las 17:06, Eyad Khalel escribió:
May someone explain me this issue in netbeans (java) : I can't find the
code which *instantiate* the *evt* object of KeyEvent Class in the
following java code which is generated by netbeans :

textPrice.addKeyListener(new java.awt.event.KeyAdapter() {
         public void keyTyped(java.awt.event.KeyEvent evt) {
             textPriceKeyTyped(evt);
         }
     });

Where can I find the source code that instantiate the *evt* object of the
KeyEvent class?

Can we call *evt* methods without instantiating it like the code below?

  private void textPriceKeyTyped(java.awt.event.KeyEvent evt) {
     // TODO add your handling code here:
     char c = evt.getKeyChar();
     if(!(Character.isDigit(c) )||(c==KeyEvent.VK_BACKSPACE) ||
(c==KeyEvent.VK_DELETE)){
     getToolkit().beep();
     evt.consume();

     }}

Thanks

Reply via email to