Win a copy of Micro Frontends in Action this week in the Server-Side JavaScript and NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Action Interface

 
Ranch Hand
Posts: 115
Eclipse IDE Tomcat Server Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what is Action Interface ? why we use Action Interface??
there are some component that provide the constructor which pass action interface object , why this used??
 
Rancher
Posts: 3205
29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How to Use Actions
 
Ranch Hand
Posts: 4716
9
Scala Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
interesting. i'm surprised i have never used Actions before
 
Ranch Hand
Posts: 41
Netbeans IDE Chrome Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First off, ActionListener is an interface, but you should call it actionListener. Secondly, you should learn about interfaces first if you don't already know: http://docs.oracle.com/javase/tutorial/java/concepts/interface.html
Basically interfaces return things when events are caused.
 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Jj Hill wrote:First off, ActionListener is an interface, but you should call it actionListener.


Why should you call it actionListener? And the question wasn't about ActionListener anyway.

Jj Hill wrote:Secondly, you should learn about interfaces first if you don't already know: http://docs.oracle.com/javase/tutorial/java/concepts/interface.html


That's a good link (as are most Oracle tutorials), but I don't think there's any reason to suppose that Jimmy doesn't understand interfaces...

Jj Hill wrote:Basically interfaces return things when events are caused.


... but I see you don't. Maybe you need to spend more time with the tutorial you recommended. From that tutorial:

Interfaces form a contract between the class and the outside world


They do not 'return things when events are caused'
 
Jj Hill
Ranch Hand
Posts: 41
Netbeans IDE Chrome Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Um, the question says "what is action interface", which implies that he doesn't know how to use interfaces (the event interfaces can be implemented all in a similar fashion). But , interfaces do return things when events are caused. Yes, the oracle definition is more precise, but that doesn't mean I'm wrong. When you write an actionListener(or any of the listener classes), you say what to do when an event is caused(from an external source). Hm, return probably wasn't a good word to use. I didn't mean the "return" keyword. I just meant that you can tell the JVM what to do when an event is caused. I know how to use actionListeners
 
Rob Camick
Rancher
Posts: 3205
29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I know how to use actionListeners



The question isn't about an ActionListener. It is about the Action interface. They are different.
 
Jj Hill
Ranch Hand
Posts: 41
Netbeans IDE Chrome Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I know. Just responding to the other guy.
 
Darryl Burke
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Jj Hill wrote:Um, the question says "what is action interface", which implies that he doesn't know how to use interfaces (the event interfaces can be implemented all in a similar fashion).


A wrong conclusion, and irrelevant.

Jj Hill wrote:But , interfaces do return things when events are caused.


They do not. As already pointed out, they form a contract between the class and the outside world.

Jj Hill wrote:Yes, the oracle definition is more precise, but that doesn't mean I'm wrong.


You are.

Jj Hill wrote:When you write an actionListener(or any of the listener classes), you say what to do when an event is caused(from an external source). Hm, return probably wasn't a good word to use. I didn't mean the "return" keyword. I just meant that you can tell the JVM what to do when an event is caused. I know how to use actionListeners


Again, irrelevant both to the question in this thread and interfaces in general. Only a small fraction of all interfaces are event listeners.

Have you read the API for javax.swing.Action? Its contract specifies much more than a mere event listener.
 
Jj Hill
Ranch Hand
Posts: 41
Netbeans IDE Chrome Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can't you think for yourself? Those two definitions are more or less EQUAL. Seriously, what do you have against me? Would you say that the definition of an actionlistener was incorrect just if I had used the word "connection" instead of "contract"?

I'm going to stop arguing with you, so I don't get banned or anything. didn't realize you were the swing forum leader.
 
Darryl Burke
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Jj Hill wrote:Can't you think for yourself?


Don't be rude!

Jj Hill wrote:Those two definitions are more or less EQUAL.


No, they're not.

Jj Hill wrote:Seriously, what do you have against me?


I have nothing at all against you, except that I take exception to the first sentence of this post of yours.

I do have something against wrong notions being posted here, as that can be misleading to others who later find the thread and read through in the hope of learning something.

Jj Hill wrote:Would you say that the definition of an actionlistener was incorrect just if I had used the word "connection" instead of "contract"?


Probably, yes.

Jj Hill wrote:I'm going to stop arguing with you, so I don't get banned or anything. didn't realize you were the swing forum leader.


You don't get banned here for an honest technical error. Just don't indulge in personal insults and you can continue the discussion if things still aren't clear.
 
Sheriff
Posts: 22004
107
Eclipse IDE Spring VI Editor Chrome Java Ubuntu Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jj Hill, please BeNice. Perhaps he hasn't phrased himself the way you would have liked, but Darryl is right.
 
Don't destroy the earth! That's where I keep all my stuff! Including this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic