+ 12
Event handler functions vs normal functions
I have noticed that with event handler functions we include a parameter which can be given a random name, usually e or ev is used and we use this var to get information about the object, the part i dont understand is were this object comes from how does ev have access to the events methods and info 😅 can anyone explain in simple please
6 Respostas
+ 8
+ 7
EventHandler is a functional interface and you define the type of Event it handles....
EventHandler<T extends Event>.
The event itself is a signal from the OS (by interrupt request - irq) and the observers of this get notfied:
https://stackoverflow.com/questions/29880768/how-events-are-generated-in-java
+ 6
The e is the object of a sub class of event class like ActionEvent class this class knows some certain info about the hardware change going on in the system
As you call them through your Event handler parameter it gets activated and does its job
+ 6
Event functions are the functions which you can rewrite the function for any object that you made.
Event functions are actually called like normal functions in class. You can call event functions in your own class or it can be already called by the framework classes itself.
If event functions have not rewritten for an object which calls the event function, then the event function will not be called.
Summary:
-Classes have event functions.
-Event functions are called in somewhere in the classes.
-Event functions should be rewritten for any object that will call the event function.
+ 4
Well event handler are included with specific parameters which can be given different name by writing var , but as I think normal function can't beat event handler
for example like in html table tag a evenhandler is onClick which response on clicking the table
like:
<table border onClick="this is a table"></table>
on clicking the table it will show , this is a table
also there are many evenhandler which are supported in html
+ 2
Thank you