What is event handling-How to handle it in Java
What is meant by event?
Event is state-change or behavior-change is called as an event
Ex:-if you take a button ,pressing on this button is an event
Event occurs when text is entered into an empty text field.That is, the empty thing changes.
In general, an event refers to a change in state or a change in behavior.
How do we handle these events?
Event handling in Java is using the delegation event model.
What is the delegation event model?
Modern concepts of event handling in Java are based on the delegation event model, whose concept is very simple: its source generates an event and sends it to one or more listeners.
sources:sources are the elements that create events
Listeners: Listeners are used for handling the events generated from the source.
Listener Interface and Supporting Components
ActionListener--> Button,List,TextField,MenuItem,and its derivatives
AdjustmentListener--> Scrollbar
KeyListener--> Component and its derivatives
MouseListener--> Component and its derivatives
WindowListener--> Window and its derivatives
ItemListener--> Checkbox,List,CheckboxMenuItems
TextListener--> TextField,TextArea
Remember the naming rules in java
Comments
Post a Comment