wood burning stoves*
The moose likes Swing / AWT / SWT and the fly likes Action Interface Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Action Interface" Watch "Action Interface" New topic
Author

Action Interface

Singh Harmeet
Ranch Hand

Joined: Aug 05, 2011
Posts: 115

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??


With Regards :-
Harmeet Singh
Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2204
    
    7
How to Use Actions
Randall Twede
Ranch Hand

Joined: Oct 21, 2000
Posts: 4347
    
    2

interesting. i'm surprised i have never used Actions before


SCJP
Visit my download page
Jj Hill
Ranch Hand

Joined: Jul 25, 2011
Posts: 41

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

Joined: May 03, 2008
Posts: 4642
    
    5

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'


luck, db
There are no new questions, but there may be new answers.
Jj Hill
Ranch Hand

Joined: Jul 25, 2011
Posts: 41

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

Joined: Jun 13, 2009
Posts: 2204
    
    7
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

Joined: Jul 25, 2011
Posts: 41

I know. Just responding to the other guy.
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4642
    
    5

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

Joined: Jul 25, 2011
Posts: 41

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

Joined: May 03, 2008
Posts: 4642
    
    5

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

Joined: Oct 27, 2005
Posts: 19723
    
  20

Jj Hill, please BeNice. Perhaps he hasn't phrased himself the way you would have liked, but Darryl is right.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Action Interface