This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Java in General and the fly likes what action listener interface is doing in this code ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "what action listener interface is doing in this code ?" Watch "what action listener interface is doing in this code ?" New topic
Author

what action listener interface is doing in this code ?

naved momin
Ranch Hand

Joined: Jul 03, 2011
Posts: 688

this is the constructor that set the clock on the label and also keep us updated with time
i now that this is done by a timer but i thing i didnt understand here is the what actionlistener interface is doing here because as far i as know action listener is occured when we want some events like clicking a button but here we are not even clicking on the label but the clock works how can any one explain ?



The Only way to learn is ...........do!
Visit my blog http://inaved-momin.blogspot.com/
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19649
    
  18

ActionListener is used for so much more than only button clicks. If it were, I think the name would be ButtonListener instead of ActionListener. Right now, I can think of several other uses:
- menu item clicks
- JTextField enter presses
- Timer, as your example has shown


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Harsha Smith
Ranch Hand

Joined: Jul 18, 2011
Posts: 287
when you invoke start() method on javax.swing.Timer object, it starts sending action events to its listeners.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: what action listener interface is doing in this code ?
 
Similar Threads
Java: Display Time
Callout Handler - receiving delayed events on the same thread
Programming style insights
Help with Timers!
Swing Timer and Date Class thread question...