What does ActionEvent e mean?

MooseMan55 picture MooseMan55 · Jul 4, 2015 · Viewed 24.7k times · Source

I am learning Java and would really like to have a deeper understanding of what the ActionEvent e perameter means and stands for. When I code I don't just want to spit out lines that work, but I don't understand. I want to have a full understanding of concepts before I use them.

So what specifically is it asking for and what do the two parts(ActionEvent and e) mean?

class ButtonListener implements ActionListener{
        @Override
        public void actionPerformed(ActionEvent e){
    }
}

Thanks.

Answer

Eric Guan picture Eric Guan · Jul 4, 2015

ActionEvent is a class, e is an instance of that class. You can use e to call it's methods/properties, found here

http://docs.oracle.com/javase/7/docs/api/java/awt/event/ActionEvent.html

ActionEvent is just a type, it informs you what type of object e is. By the way, you can change e to whatever you prefer, for ex. event or object.

ActionEvent event, ActionEvent object (remember, not to be confused with Object, its object with lower case "o"), ActionEvent anyVariableName etc...

Then inside actionPerformed() you can call stuff like event.doSomething();