• Post Reply Bookmark Topic Watch Topic
  • New Topic

What can actionlistener do?  RSS feed

 
Serap Elbeyoglu
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am studying on actionListener method.

for example: I created a button & wanted to know how many times user clicked on my button. Then, I wrote actionListener method to know the number of clicks.

I think, I can know number of my web page visits.

I suppose, actionListener helps me to know how long you have been online in my website.

Can you give me another example like this?



 
Sebastian Janisch
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
An ActionListener is added to a component and is invoked when the action happened. It comes with an ActionEvent that gives you information about the event.

You would for instance add an ActionListener to a button and the method actionPerformed gets invoked when the button has been clicked.
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A JButton which is usually the source for the action event (trapped by the action listener) cannot be added directly to a web page unless you are using applets. In other words, the button which you see on web pages inside a browser are not JButton instances.
 
Serap Elbeyoglu
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for your post Maneesh, can you give me another example about actionListener?

Today, I learned that my program can print user's mouse actions in a specific area and time. right, left, up, down, double click etc. What else can you say? Do you know some examples which are coded with actionListener method?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!