   [java] newbie need java event help
  the subject says it all im a newbie that is having trouble using events and listeners. esspecially to detect a keyhit. could anyone send me code that uses this stuff?!?!?!email: johnhimics@154throckmorton.comTHX in advance!! :>) 
  You sound like you need a book.  Here, let me give you some pointers.Google.Amazon.Barnes & Noble.Hope those help.   The Artist Formerly Known as CmndrMhttp://chaos.webhop.org;  I''ll make a brief description of what listeners and events are. First, you have event sources, such as a JButton, and you want to register your interest in that button by implementing a listener (for a button, it could be ActionListener, MouseListener, etc). Now, whenever an action is made on that event source (such as clicking on the button), an event object is sent by the event source to the listener that you implemented. So basically, 1) create an event source 2) implement a listener interface 3) register the event source with the listener interface (ex. button.addActionListener(MyActionListener)).If I recommend anything, it would be the book "Head First Java" by Kathy Sierra and Bert Bates. At first glance, I thought it was to "kiddy", but actually all the pictures and the diagrams truly made some of the subject material easier to understand. Hope this helps a little bit.  ;quote:You sound like you need a book. Here, let me give you some pointers.  There are no pointers in Java!! :Dimport java.awt.*;import java.awt.event.*;import java.applet.Applet;public class MyActionListener extends Applet implements ActionListener{// the class doesn't have to extend applet, but it must implement some sort of Listener interface(I'm assuming you know what those are)  private Button Mybutton; // A button to be clicked =)  public void init(){    Mybutton = new Button("Click Me!");    Mybutton.addActionListener(this); // Sets the instance of MyActionListener to "listen" to the button.  When something happens ActionPerformed() is executed.  }  public void start(){    add("Center", Mybutton); //puts the button in the center of the applet  }  public void ActionPerformed(ActionEvent ae){    // do whatever you wanted to do here.  This method is executed when the button is clicked  }}edit: just to make a smartass remark   [edited by - TreizeSG on August 2, 2003 8:03:29 AM];  Have you tried sun.java.com? They have huge amounts of tutorials. And they are excellent.Here's one on events and eventslisteners: Lesson: Writing Event Listeners .   -+-+-+-+-+-+-+-+-+-+-+-+-+-+-Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius -- and a lot of courage -- to move in the opposite direction.   [edited by - rohde on July 31, 2003 9:02:05 AM];  Thx everyone ill look into the books and the code. i think i just might understand it.  