1 / 21

Java Events

Java Events. Overridden method: is an action that happens between a base(super) class and its child when they have the same method.

hayes
Download Presentation

Java Events

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Java Events

  2. Overridden method: is an action that happens between a base(super) class and its child when they have the same method

  3. An Abstract class is the same as a regular class except it has one or more methods that are not implemented ie they are declared but have no executable code; so yes, they can have constructors.

  4. An Interface canonly have variables which are constants. Methods can be declared BUT can have no executable code. All interface methods are implicitly abstract. An Interface does not have a constructor; as you cannot create an instance of an Interface. They guarantee behavior, not how the behavior occurs.

  5. In Javayou can only inherit from one class using the keyword (Extends) and inherit from one or more interface using the keyword (Implements)

  6. Event Handling Any program that uses GUI such as java applications written for windows is event driven, event describes the change of state of any object. Example: Pressing a button, entering a character in a textbox.

  7. Components of the Event 1. Event Sources2. Event classes3. Event Listeners4. Event Adapters

  8. Event Sources Event sources are components, subclasses of java.awt.Component, capable to generate events. The event source can be a button,TextField or a Frame etc. An object that generates an event.

  9. Event Classes Almost every event source generates an event and is named by some Java class.

  10. Example

  11. The events generated by hardware components (like MouseEvent and KeyEvent) are known as low-level events and the events generated by software components (like Button, List) are known as semantic events

  12. Event Listeners The events generated by the GUI components are handled by a special group of interfaces known as listeners. They’re an interface. Every component has its own listener. Listeners are from java.awt.eventpackage.

  13. Event Adapter When a listener includes many abstract methods to override, the coding becomes heavy to the programmer. For example, to close the frame, you override seven abstract methods of WindowsListener, in which, in fact you are using only one method.

  14. Event Adapter To avoid this heavy coding, the designers come with another group of classes known as "adapters". Adapters are abstract classes defined in java.awt.event package. Every listener that has more than one abstract method has got a corresponding adapter class.

More Related