• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Action Interface

 
Singh Harmeet
Ranch Hand
Posts: 115
Eclipse IDE Java Tomcat Server
  • 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??
 
Rob Camick
Ranch Hand
Posts: 2613
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How to Use Actions
 
Randall Twede
Ranch Hand
Posts: 4469
3
Java Python Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
interesting. i'm surprised i have never used Actions before
 
Jj Hill
Ranch Hand
Posts: 41
Chrome Java Netbeans IDE
  • 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.
 
Darryl Burke
Bartender
Posts: 5148
11
Java Netbeans IDE Opera
  • 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
Chrome Java Netbeans IDE
  • 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
Ranch Hand
Posts: 2613
9
  • 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
Chrome Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I know. Just responding to the other guy.
 
Darryl Burke
Bartender
Posts: 5148
11
Java Netbeans IDE Opera
  • 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
Chrome Java Netbeans IDE
  • 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: 5148
11
Java Netbeans IDE Opera
  • 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.
 
Rob Spoor
Sheriff
Pie
Posts: 20611
63
Chrome Eclipse IDE Java 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic