Добавить
Уведомления

Java Event Handling #java #javatutorial #javaprogramming

Java Event Handling #java #javatutorial #javaprogramming Event Handling: Introduction : Event handling is of fundamental importance to programs with a GUI. The java AWT event model works and how to use the simplest GUI elements. Jdk Basic functions : 1- Creation of user interface components such as buttons , labels. 2- Support for giving behavior to the components by GUI events (buttionclick, mouseclick) 3- Support for grouping and arranging the components on the screen. 4- Support for accessing window manager facilities like that input focus , reading , JPEG and other image files and printing. On screen buttons, menus , frames or other elements the user will touch next. This is known as event driven programming. One flow of control beginning to end, the runtime system sits in a window main loop simply waiting for user input. When turns it into an event and passes it on to a handler. This is known as callback. Basics of event handling: 1- Declare and initialize event sources – buttons , menus , choices 2- Implement an interface to provide the event handler that responds to event. 3- Register this event handler with event source. 4- Add the event source to the container like applet , frame, panel etc. Event delegation model An event source produces events and dispatches them to all registers event listeners. A single class can implement multiple listener interfaces. A single listener object can register with multiple event sources. Multiple listener objects can register with a single event source( multicast). Events: is the encapsulation of some user input delivered to the application asynchronously. AWT events is a root class of all AWT events. AWTEvent is subclassed as : ActionEvent , WindowEvent , ItemEvent, KeyEvent, MouseEvent, TextEvent. Evetn Listener Interfaces : Java we have a number of built in interfaces as listeners for different types of event handlings. Interface Events Generated by ActionLIstener Button , list , menuitem , textfield AdjustmentListner- Scrollbar ItemListener: checkbox, checkboxmenuitem , choice , list Textlistener: TextComponents ComponentListener: Component CaontianerListener: Container WindowListnener: Window Handling Windows Events: windowListener interface has seven methods: Public void windowClosing(WindowEvent e); Public void windowClosed(WindowEvent e); Public void windowOpened(WindowEvent e); Public void windowIconified(WindowEvent e); Public void windowDeIconoified(WindowEvent e); Public void windowActivated(WindowEvent e); Public void windowDeactivated(WindowEvent e); @Crazy @crazy XYZ @MrBeast @utkarshclasses13 @MrIndianHacker @elvishyadavVlogs @MagnetBrainsEducation Using a Listener Adapter Class : To make a things a little more convenient a concept called adaptor classes can be used. Compound Adapter Mouse Motion Adapter Container Adapter Focus Adaptor Key Adapter

Иконка канала Кодовый карнавал
5 подписчиков
12+
15 просмотров
2 года назад
4 декабря 2023 г.
12+
15 просмотров
2 года назад
4 декабря 2023 г.

Java Event Handling #java #javatutorial #javaprogramming Event Handling: Introduction : Event handling is of fundamental importance to programs with a GUI. The java AWT event model works and how to use the simplest GUI elements. Jdk Basic functions : 1- Creation of user interface components such as buttons , labels. 2- Support for giving behavior to the components by GUI events (buttionclick, mouseclick) 3- Support for grouping and arranging the components on the screen. 4- Support for accessing window manager facilities like that input focus , reading , JPEG and other image files and printing. On screen buttons, menus , frames or other elements the user will touch next. This is known as event driven programming. One flow of control beginning to end, the runtime system sits in a window main loop simply waiting for user input. When turns it into an event and passes it on to a handler. This is known as callback. Basics of event handling: 1- Declare and initialize event sources – buttons , menus , choices 2- Implement an interface to provide the event handler that responds to event. 3- Register this event handler with event source. 4- Add the event source to the container like applet , frame, panel etc. Event delegation model An event source produces events and dispatches them to all registers event listeners. A single class can implement multiple listener interfaces. A single listener object can register with multiple event sources. Multiple listener objects can register with a single event source( multicast). Events: is the encapsulation of some user input delivered to the application asynchronously. AWT events is a root class of all AWT events. AWTEvent is subclassed as : ActionEvent , WindowEvent , ItemEvent, KeyEvent, MouseEvent, TextEvent. Evetn Listener Interfaces : Java we have a number of built in interfaces as listeners for different types of event handlings. Interface Events Generated by ActionLIstener Button , list , menuitem , textfield AdjustmentListner- Scrollbar ItemListener: checkbox, checkboxmenuitem , choice , list Textlistener: TextComponents ComponentListener: Component CaontianerListener: Container WindowListnener: Window Handling Windows Events: windowListener interface has seven methods: Public void windowClosing(WindowEvent e); Public void windowClosed(WindowEvent e); Public void windowOpened(WindowEvent e); Public void windowIconified(WindowEvent e); Public void windowDeIconoified(WindowEvent e); Public void windowActivated(WindowEvent e); Public void windowDeactivated(WindowEvent e); @Crazy @crazy XYZ @MrBeast @utkarshclasses13 @MrIndianHacker @elvishyadavVlogs @MagnetBrainsEducation Using a Listener Adapter Class : To make a things a little more convenient a concept called adaptor classes can be used. Compound Adapter Mouse Motion Adapter Container Adapter Focus Adaptor Key Adapter

, чтобы оставлять комментарии