Presentation is loading. Please wait.

Presentation is loading. Please wait.

Responding to Events Event Handling in Java

Similar presentations


Presentation on theme: "Responding to Events Event Handling in Java"— Presentation transcript:

1 Responding to Events Event Handling in Java
Making the UI Work Responding to Events Event Handling in Java

2 Event Handling Event Handling Consist of the following 3 things Events
Event Sources / Generators Event Listeners / Handlers 3/19/ :06:58 PM Property of N++ Studios

3 Event An action which is recognized by an object is known as an Event
For example. Moving the mouse pointer over button and clicking over the button Specific Event Listeners are available for handling specific events. 3/19/ :06:58 PM Property of N++ Studios

4 Some Events, ActionEvent ItemEvent AdjustmentEvent KeyEvent
Such as mouse clicks and Enter key presses ItemEvent Such as selecting an item from a dropdown list box AdjustmentEvent Such as moving a scrollbar KeyEvent Such as pressing a key on the Keyboard 3/19/ :06:58 PM Property of N++ Studios

5 Event Sources / Generators
Components which can generate the events are commonly known as event sources or event generators. Examples Button Scrollbar Checkbox Choice TextField 3/19/ :06:58 PM Property of N++ Studios

6 Event Listeners / Handlers
These are special kind of java Interfaces (type of java program) that is used to handle the events. Each Listener is built with one or more methods to respond to event, Before these Listeners can handle the events for you, you must register the components with the relevant Event Listener refer the code samples for more information. 3/19/ :06:58 PM Property of N++ Studios

7 Question (s) Create an UI with two buttons, when you click on the first button the second button’s position should change. Create an UI to enter a number and display in a label EVEN or ODD with 2 different colors Create an UI with two TextFields and one button once you type something in the TextField and click the button count the number of characters in the 1st textfield and display it in the 2nd TextField. 3/19/ :06:58 PM Property of N++ Studios

8


Download ppt "Responding to Events Event Handling in Java"

Similar presentations


Ads by Google