File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

what action listener interface is doing in this code ?

 
naved momin
Ranch Hand
Posts: 692
Eclipse IDE Java Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ?

 
Rob Spoor
Sheriff
Pie
Posts: 20388
46
Chrome Eclipse IDE Java Windows
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Harsha Smith
Ranch Hand
Posts: 287
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic