The document discusses Java event handling and GUI components. It defines events as objects that describe user actions, and event handlers as methods that process events from components like buttons. It explains how to create listeners for common event types like action events and mouse clicks, and how to add menus, menu items, and control colors in Java GUI applications.
The document provides an overview of key Java programming concepts including: the features of Java technology; the primary goals and functions of the Java Virtual Machine and garbage collection; how Java source files are compiled and executed; the three main tasks of the JVM; modeling concepts like abstraction and encapsulation; and how to declare classes, methods, and constructors in Java. It also summarizes how packages, imports, and the Java API documentation work.
The document provides an overview of object-oriented programming using C#. It discusses the rationale for using an object-oriented approach and describes the key concepts like classes, objects, states, behaviors, and interactions. It also outlines the objectives of learning about features of OOP methodology, defining classes and variables in C#, and writing and executing C# programs. The document uses examples like a car class to illustrate concepts like classes, objects, states and behaviors.
The document discusses object-oriented programming using C#. It covers using static variables and functions, components of the .NET framework including the common language runtime and class library, and using the Visual Studio IDE to create and run projects. Specifically, it will teach how to use static variables and functions, identify .NET framework components, and use the Visual Studio IDE.
This document discusses object-oriented programming concepts in C#, including constructors, destructors, polymorphism, function overloading, and operator overloading. Constructors initialize objects, destructors release objects from memory, and polymorphism allows one interface to have multiple implementations. Function overloading uses the same name for functions that differ in parameters, while operator overloading extends operators to user-defined types.
This document discusses object-oriented programming using C#. It covers multiple topics related to multithreading like implementing multiple threads, identifying thread priority, using synchronization in threads, and communication between processes. It also provides an example of developing a Hangman game application.
The document discusses object-oriented programming using C# and covers several topics:
1) Handling exceptions by using try, catch, and finally blocks to handle errors.
2) Implementing user-defined exceptions by deriving from the ApplicationException class.
3) Implementing threads to allow concurrent execution, with the main thread created automatically and additional child threads created using the Thread class.
The document discusses object-oriented programming concepts in C#, including overloading unary and binary operators, identifying relationships between classes like inheritance and composition, and using classes and inheritance. It provides examples and demonstrations of these concepts.
This document discusses object-oriented programming concepts in C#, including delegates, events, and attributes. It explains that delegates allow methods to be passed as arguments and invoked, and that there are single-cast and multicast delegates. Events use the publisher-subscriber model where a publisher raises an event and subscribers handle the event. Attributes provide metadata for classes, methods and other code elements.
The document provides an overview of key Java programming concepts including: the features of Java technology; the primary goals and functions of the Java Virtual Machine and garbage collection; how Java source files are compiled and executed; the three main tasks of the JVM; modeling concepts like abstraction and encapsulation; and how to declare classes, methods, and constructors in Java. It also summarizes how packages, imports, and the Java API documentation work.
The document provides an overview of object-oriented programming using C#. It discusses the rationale for using an object-oriented approach and describes the key concepts like classes, objects, states, behaviors, and interactions. It also outlines the objectives of learning about features of OOP methodology, defining classes and variables in C#, and writing and executing C# programs. The document uses examples like a car class to illustrate concepts like classes, objects, states and behaviors.
The document discusses object-oriented programming using C#. It covers using static variables and functions, components of the .NET framework including the common language runtime and class library, and using the Visual Studio IDE to create and run projects. Specifically, it will teach how to use static variables and functions, identify .NET framework components, and use the Visual Studio IDE.
This document discusses object-oriented programming concepts in C#, including constructors, destructors, polymorphism, function overloading, and operator overloading. Constructors initialize objects, destructors release objects from memory, and polymorphism allows one interface to have multiple implementations. Function overloading uses the same name for functions that differ in parameters, while operator overloading extends operators to user-defined types.
This document discusses object-oriented programming using C#. It covers multiple topics related to multithreading like implementing multiple threads, identifying thread priority, using synchronization in threads, and communication between processes. It also provides an example of developing a Hangman game application.
The document discusses object-oriented programming using C# and covers several topics:
1) Handling exceptions by using try, catch, and finally blocks to handle errors.
2) Implementing user-defined exceptions by deriving from the ApplicationException class.
3) Implementing threads to allow concurrent execution, with the main thread created automatically and additional child threads created using the Thread class.
The document discusses object-oriented programming concepts in C#, including overloading unary and binary operators, identifying relationships between classes like inheritance and composition, and using classes and inheritance. It provides examples and demonstrations of these concepts.
This document discusses object-oriented programming concepts in C#, including delegates, events, and attributes. It explains that delegates allow methods to be passed as arguments and invoked, and that there are single-cast and multicast delegates. Events use the publisher-subscriber model where a publisher raises an event and subscribers handle the event. Attributes provide metadata for classes, methods and other code elements.
The document provides an overview of key Java programming concepts including final classes and methods, enumerated types, static imports, abstract classes and interfaces, exceptions, assertions, and creating custom exceptions. It discusses how to use these concepts and includes code examples.
The document discusses creating and using custom attributes in C#. It explains how to define a custom attribute class, apply the AttributeUsage attribute, name and construct the attribute, and apply it to a target element. It also covers retrieving metadata about custom attributes at runtime using reflection and the main uses of reflection like viewing metadata, type discovery, and late binding.
This document provides an introduction and overview of the Java programming language, including its history, features, and components. It discusses how Java was developed in 1995 at Sun Microsystems and introduced as a platform-independent language for general business applications and web-based internet applications. It also summarizes Java's key features like being object-oriented, compiled and interpreted, and portable, as well as its core architecture components like the Java programming language, Java Virtual Machine, and Java API.
The document discusses Java Swing basics including what is a user interface, what is the Abstract Window Toolkit (AWT), what is Java API, advantages of Swing over AWT, Model-View-Controller (MVC) architecture, components and containers in Swing, creating a frame in Swing, and a program to display a frame with two images. Key points include: AWT provides basic GUI components but Swing provides more powerful and flexible lightweight components; Swing uses a modified MVC architecture called Model-Delegate; components are GUI elements and containers hold and arrange components; a frame is a top-level window container that can hold other components.
The document discusses using dry run tables and iteration in programming logic and techniques. It provides examples of using dry run tables to step through sample data and evaluate program output. It also provides examples of using iteration and loops to repeatedly perform steps, such as summing a series of numbers or collecting details from a list of employees. The document demonstrates creating flowcharts to represent iterative logic and using dry run tables to test sample data.
The document provides information about Java, including:
- Java is an object-oriented programming language that is platform independent and can be used to create applications for web, desktops, mobile devices, and more.
- Java was originally developed in the early 1990s by James Gosling at Sun Microsystems for use in set-top boxes, but became popular for building web applications and is now widely used.
- The Java Development Kit (JDK) includes tools like javac, java, javadoc and others needed to develop, compile, run and document Java programs, as well as class libraries and documentation. The JVM executes compiled Java code.
Java is a platform independent, object-oriented programming language. Key features include encapsulation, inheritance, polymorphism and abstraction. The document discusses these object-oriented programming concepts and compares abstraction and encapsulation. It also answers various questions about Java topics like the JVM, static methods, collections, threads and more.
This document provides a history and overview of the Java programming language. It discusses:
1. James Gosling developed Java in 1991 at Sun Microsystems. The first public release was in 1995. Java is an object-oriented language similar to C and C++ but without pointers.
2. Java is widely used for desktop applications, web applications, mobile apps, embedded systems, smart cards, robotics, and games. It is popular due to being platform-independent, distributed, secure, robust, high-performance, and multithreaded.
3. The document provides examples of Java code, including "Hello World" and code demonstrating if/else statements, for loops, methods, and classes.
This document provides instructions on how to start programming in Java. It discusses installing the Java Development Kit (JDK) which allows compiling and running Java applications. It also covers using the Eclipse integrated development environment and creating a basic Java project within Eclipse. The document then introduces some key Java concepts like primitive data types, operators, and strings.
This document provides an introduction and overview of the Java programming language. It discusses that Java was developed by Sun Microsystems in the 1990s as a general-purpose, object-oriented language designed for easy web and internet applications. The key principles of object-oriented programming like encapsulation, inheritance, and polymorphism are explained. Characteristics of Java like being simple, secure, portable, and having good performance are highlighted. A brief history of Java's development is also presented.
Java was developed by Sun Microsystems in 1991 as a simple yet robust programming language. It is an object-oriented language that allows for abstraction, encapsulation, inheritance, and polymorphism. To compile and run a Java program, developers write code in an editor, save it with a .java extension, compile it to generate a .class file using javac, and execute the bytecode using java without specifying the file extension. The Java Virtual Machine then interprets and executes the bytecode, allocating memory and threads as needed.
Here are the key methods in the Color class:
- Color(int red, int green, int blue) - Creates a color with the specified red, green, and blue values.
- static Color getColor(String colorName) - Returns a predefined color specified by name, such as "red", "blue", etc.
- int getRed() - Returns the red component of this color.
- int getGreen() - Returns the green component of this color.
- int getBlue() - Returns the blue component of this color.
So in summary, the Color class allows you to create colors from RGB values or predefined names, and retrieve the RGB components of existing colors. This enables
This chapter introduces Java GUI programming using Swing. It discusses the motivations for using Swing over AWT, outlines the objectives to be covered, and provides examples of creating basic Swing components like buttons, labels, text fields etc. It also explains the Swing and AWT class hierarchies with Container and Helper classes.
This document provides a summary of basic Java concepts including data types, operators, flow control statements, comments, and some key Java packages. It lists common Java operators like arithmetic, relational, logical, and bitwise operators. It also summarizes common statements for flow control including if/else, while, do-while, and for loops. Additionally, it shows how to declare variables, arrays, and classes in Java.
The document discusses asynchronous programming, multithreading, and assemblies in .NET. It covers implementing asynchronous methods using components like BackgroundWorker, coordinating threads through classes in the System.Threading namespace, and working with assemblies including creating strong-named assemblies, calling assemblies, and installing assemblies in the global assembly cache.
Vibrant Technologies is headquarted in Mumbai,India.We are the best Java training provider in Navi Mumbai who provides Live Projects to students.We provide Corporate Training also.We are Best Java classes in Mumbai according to our students and corporators
The document discusses identifying the benefits of multithreading, which includes performing multiple tasks in parallel, better utilization of system resources, and increasing application speed. It also covers designing applications using threads by assigning different threads to different functions to improve functionality and performance. Finally, it discusses complexities that can arise with multithreaded applications like race conditions, critical regions, mutual exclusion, synchronization, and deadlocks.
The document describes developing a programmer's editor in Java that supports various features like syntax highlighting, compilation support, and debugging support. It provides algorithms and procedures for implementing syntax highlighting, compilation, debugging, tool tips, and a task manager. The program code provided implements these features in a Java GUI application with menus, buttons, text areas for code editing and output, and listeners for user interactions like key presses.
This document provides an overview of a presentation on Java fundamentals by Kunal V. Gadhi. It covers topics such as the history and features of Java, object-oriented programming concepts, Java applications and applets, multithreading, input/output and networking, MySQL, and JDBC. The document includes sections on each topic with descriptions of key concepts and code examples.
Visual Studio Automation Object Model. EnvDTE interfacesPVS-Studio
This article contains an overview of Visual Studio Automation Object Model. Model's overall structure and the means of obtaining access to its interfaces through DTE/DTE2 top level objects are examined. Several examples of utilizing elements of the model are provided. Also discussed are the issues of using model's interfaces within multithreaded applications; an example of implementing such mechanism for multithreaded interaction with COM interfaces in managed code is provided as well.
The document discusses event handling and exceptions in Java. It covers event-driven programming, event classes, listeners, and delegation models. It also covers exception handling, common exception types like IOException and NullPointerException, using try/catch blocks to handle exceptions, and best practices for exception handling in Java programs.
The document discusses various event handling classes in Java including ActionEvent, KeyEvent, MouseEvent, MouseMotionEvent, FocusEvent, WindowEvent, and ItemEvent. It provides examples of how to use each event class by implementing the appropriate listener interface and defining event handling methods. Key points covered include common event handling terms like event, event source, and event listener. It also summarizes the typical methods provided by each event class.
The document provides an overview of key Java programming concepts including final classes and methods, enumerated types, static imports, abstract classes and interfaces, exceptions, assertions, and creating custom exceptions. It discusses how to use these concepts and includes code examples.
The document discusses creating and using custom attributes in C#. It explains how to define a custom attribute class, apply the AttributeUsage attribute, name and construct the attribute, and apply it to a target element. It also covers retrieving metadata about custom attributes at runtime using reflection and the main uses of reflection like viewing metadata, type discovery, and late binding.
This document provides an introduction and overview of the Java programming language, including its history, features, and components. It discusses how Java was developed in 1995 at Sun Microsystems and introduced as a platform-independent language for general business applications and web-based internet applications. It also summarizes Java's key features like being object-oriented, compiled and interpreted, and portable, as well as its core architecture components like the Java programming language, Java Virtual Machine, and Java API.
The document discusses Java Swing basics including what is a user interface, what is the Abstract Window Toolkit (AWT), what is Java API, advantages of Swing over AWT, Model-View-Controller (MVC) architecture, components and containers in Swing, creating a frame in Swing, and a program to display a frame with two images. Key points include: AWT provides basic GUI components but Swing provides more powerful and flexible lightweight components; Swing uses a modified MVC architecture called Model-Delegate; components are GUI elements and containers hold and arrange components; a frame is a top-level window container that can hold other components.
The document discusses using dry run tables and iteration in programming logic and techniques. It provides examples of using dry run tables to step through sample data and evaluate program output. It also provides examples of using iteration and loops to repeatedly perform steps, such as summing a series of numbers or collecting details from a list of employees. The document demonstrates creating flowcharts to represent iterative logic and using dry run tables to test sample data.
The document provides information about Java, including:
- Java is an object-oriented programming language that is platform independent and can be used to create applications for web, desktops, mobile devices, and more.
- Java was originally developed in the early 1990s by James Gosling at Sun Microsystems for use in set-top boxes, but became popular for building web applications and is now widely used.
- The Java Development Kit (JDK) includes tools like javac, java, javadoc and others needed to develop, compile, run and document Java programs, as well as class libraries and documentation. The JVM executes compiled Java code.
Java is a platform independent, object-oriented programming language. Key features include encapsulation, inheritance, polymorphism and abstraction. The document discusses these object-oriented programming concepts and compares abstraction and encapsulation. It also answers various questions about Java topics like the JVM, static methods, collections, threads and more.
This document provides a history and overview of the Java programming language. It discusses:
1. James Gosling developed Java in 1991 at Sun Microsystems. The first public release was in 1995. Java is an object-oriented language similar to C and C++ but without pointers.
2. Java is widely used for desktop applications, web applications, mobile apps, embedded systems, smart cards, robotics, and games. It is popular due to being platform-independent, distributed, secure, robust, high-performance, and multithreaded.
3. The document provides examples of Java code, including "Hello World" and code demonstrating if/else statements, for loops, methods, and classes.
This document provides instructions on how to start programming in Java. It discusses installing the Java Development Kit (JDK) which allows compiling and running Java applications. It also covers using the Eclipse integrated development environment and creating a basic Java project within Eclipse. The document then introduces some key Java concepts like primitive data types, operators, and strings.
This document provides an introduction and overview of the Java programming language. It discusses that Java was developed by Sun Microsystems in the 1990s as a general-purpose, object-oriented language designed for easy web and internet applications. The key principles of object-oriented programming like encapsulation, inheritance, and polymorphism are explained. Characteristics of Java like being simple, secure, portable, and having good performance are highlighted. A brief history of Java's development is also presented.
Java was developed by Sun Microsystems in 1991 as a simple yet robust programming language. It is an object-oriented language that allows for abstraction, encapsulation, inheritance, and polymorphism. To compile and run a Java program, developers write code in an editor, save it with a .java extension, compile it to generate a .class file using javac, and execute the bytecode using java without specifying the file extension. The Java Virtual Machine then interprets and executes the bytecode, allocating memory and threads as needed.
Here are the key methods in the Color class:
- Color(int red, int green, int blue) - Creates a color with the specified red, green, and blue values.
- static Color getColor(String colorName) - Returns a predefined color specified by name, such as "red", "blue", etc.
- int getRed() - Returns the red component of this color.
- int getGreen() - Returns the green component of this color.
- int getBlue() - Returns the blue component of this color.
So in summary, the Color class allows you to create colors from RGB values or predefined names, and retrieve the RGB components of existing colors. This enables
This chapter introduces Java GUI programming using Swing. It discusses the motivations for using Swing over AWT, outlines the objectives to be covered, and provides examples of creating basic Swing components like buttons, labels, text fields etc. It also explains the Swing and AWT class hierarchies with Container and Helper classes.
This document provides a summary of basic Java concepts including data types, operators, flow control statements, comments, and some key Java packages. It lists common Java operators like arithmetic, relational, logical, and bitwise operators. It also summarizes common statements for flow control including if/else, while, do-while, and for loops. Additionally, it shows how to declare variables, arrays, and classes in Java.
The document discusses asynchronous programming, multithreading, and assemblies in .NET. It covers implementing asynchronous methods using components like BackgroundWorker, coordinating threads through classes in the System.Threading namespace, and working with assemblies including creating strong-named assemblies, calling assemblies, and installing assemblies in the global assembly cache.
Vibrant Technologies is headquarted in Mumbai,India.We are the best Java training provider in Navi Mumbai who provides Live Projects to students.We provide Corporate Training also.We are Best Java classes in Mumbai according to our students and corporators
The document discusses identifying the benefits of multithreading, which includes performing multiple tasks in parallel, better utilization of system resources, and increasing application speed. It also covers designing applications using threads by assigning different threads to different functions to improve functionality and performance. Finally, it discusses complexities that can arise with multithreaded applications like race conditions, critical regions, mutual exclusion, synchronization, and deadlocks.
The document describes developing a programmer's editor in Java that supports various features like syntax highlighting, compilation support, and debugging support. It provides algorithms and procedures for implementing syntax highlighting, compilation, debugging, tool tips, and a task manager. The program code provided implements these features in a Java GUI application with menus, buttons, text areas for code editing and output, and listeners for user interactions like key presses.
This document provides an overview of a presentation on Java fundamentals by Kunal V. Gadhi. It covers topics such as the history and features of Java, object-oriented programming concepts, Java applications and applets, multithreading, input/output and networking, MySQL, and JDBC. The document includes sections on each topic with descriptions of key concepts and code examples.
Visual Studio Automation Object Model. EnvDTE interfacesPVS-Studio
This article contains an overview of Visual Studio Automation Object Model. Model's overall structure and the means of obtaining access to its interfaces through DTE/DTE2 top level objects are examined. Several examples of utilizing elements of the model are provided. Also discussed are the issues of using model's interfaces within multithreaded applications; an example of implementing such mechanism for multithreaded interaction with COM interfaces in managed code is provided as well.
The document discusses event handling and exceptions in Java. It covers event-driven programming, event classes, listeners, and delegation models. It also covers exception handling, common exception types like IOException and NullPointerException, using try/catch blocks to handle exceptions, and best practices for exception handling in Java programs.
The document discusses various event handling classes in Java including ActionEvent, KeyEvent, MouseEvent, MouseMotionEvent, FocusEvent, WindowEvent, and ItemEvent. It provides examples of how to use each event class by implementing the appropriate listener interface and defining event handling methods. Key points covered include common event handling terms like event, event source, and event listener. It also summarizes the typical methods provided by each event class.
This document provides an overview of key Java programming concepts including casting objects, overloading methods and constructors, wrapper classes, autoboxing, and using static variables and methods. Specifically, it discusses casting objects to access subclass functionality, defining methods with the same name but different parameters, using variable arguments, invoking parent class constructors, the equals() and toString() methods of the Object class, boxing and unboxing primitive types, and declaring static class members.
The document discusses various topics in JDBC including prepared statements, transactions, batch updates, stored procedures, and metadata. Prepared statements allow passing parameters to SQL statements and improve performance. Transactions commit or rollback multiple statements as a single unit. Batch updates execute a group of statements together more efficiently. Stored procedures are called using CallableStatement and parameters can be IN, OUT, or INOUT. Database metadata describes database structure and result set metadata describes result columns.
This document discusses event handling in Java. It covers event classes like ActionEvent and MouseEvent which describe changes in GUI components. Listeners register with sources to receive event notifications. The delegation model allows specifying objects to notify for specific events. Common sources and event types are described. Interface and adapter classes support defining event handler methods.
The document discusses Java event handling and various listener interfaces. It describes the delegation event model where an event source generates an event and sends it to registered listeners. It outlines common listener interfaces like ActionListener, ItemListener, KeyListener, MouseListener, and WindowListener. It provides details on the methods in each interface and how to write classes that implement the listener interfaces.
This document provides an overview of key Java programming concepts including: identifiers, primitive and reference data types, variables, objects, casting, conditional statements like if/else and switch, and looping statements like for, while, and do-while loops. It describes how to declare variables, construct objects, pass arguments, use this, and control flow with break/continue. The goal is to teach basic Java syntax and programming structures.
The document discusses event handling in Java, describing different types of events like window, mouse, and keyboard events. It explains the event handling process and different event classes. Various listener interfaces are described that can be implemented to handle specific events, such as WindowListener, MouseListener, and KeyListener.
The document discusses object oriented programming concepts like events, event sources, event classes, event listeners, and the delegation event model. It describes how events like mouse clicks and keyboard presses are handled in Java. It provides details on common event classes like MouseEvent and KeyEvent. It also discusses components of the AWT class hierarchy like labels, buttons, text fields, and scrollbars, and how to handle user interface events with them.
This document discusses event handling in Java. It provides an introduction to event handling, the delegation event model, common event packages and classes in Java. It describes key concepts like events, event sources, event listeners, and how they interact in the delegation model. It provides examples of specific event classes like KeyEvent, ActionEvent, ItemEvent and the corresponding listener interfaces. It also demonstrates sample code for common listeners.
Training on java niit (sahil gupta 9068557926)Sahil Gupta
Java is a popular, object-oriented programming language that is platform independent and can be used to create a variety of applications including desktop applications, web applications, games, and mobile applications. Java uses concepts like classes, objects, inheritance, polymorphism, abstraction, and encapsulation to simplify software development and maintenance. Abstraction in Java is achieved through mechanisms like abstract classes and interfaces to hide internal details and show only functionality to the user.
This document provides an overview of key concepts to be covered in a Java programming language session, including:
1. Writing programs that use command-line arguments, system properties, and standard input/output.
2. Creating, reading and writing files.
3. Understanding the basic collections hierarchy and writing programs using sets, lists, and generic collections.
4. Iterating over collections.
This document discusses object-oriented programming concepts. It defines encapsulation, abstraction, inheritance, and polymorphism as key features of OOP. Encapsulation hides implementation details and abstraction focuses on essential object characteristics. Inheritance creates a class hierarchy for code reuse. Relationship types between classes include kind-of, is-a, part-of, and has-a. Inheritance can be single, from one superclass, or multiple, from more than one. Polymorphism means an entity takes on different meanings in different contexts.
- Java AWT (Abstract Windowing Toolkit) is an API that provides components to build graphical user interfaces (GUIs) in Java. It includes classes like TextField, Label, TextArea, etc.
- AWT components are platform-dependent and heavyweight, using operating system resources. Common containers include Frame, Dialog, and Panel.
- This document provides details on various AWT components like Label, Button, Checkbox, List, and TextField. It also covers events, listeners, and methods of these components.
The document discusses legacy connectivity and protocols. It describes legacy integration as integrating J2EE components with legacy systems. The key approaches to legacy integration are data level integration, application interface integration, method level integration, and user interface level integration. Legacy connectivity can be achieved using Java Native Interface (JNI), J2EE Connector Architecture, and web services. JNI allows Java code to call native methods written in other languages like C/C++. The J2EE Connector Architecture standardizes connectivity through resource adapters. Web services provide a platform-independent approach through XML protocols.
The document discusses event handling in Java. It defines an event as a user action and describes how the Java runtime notifies programs of events instead of programs actively waiting for the events. It describes low-level events like keyboard and mouse events, and semantic events specific to components. It outlines the class hierarchies for different event types and describes the listener interfaces and their methods for responding to events.
The document discusses GUI programming concepts in Java. It covers the basics of event-driven programming using Swing components like JLabel, JButton etc. It explains how to create a simple GUI application using a JFrame container, adding components, registering event listeners and writing event handler methods. The key aspects are creating Swing components, adding them to containers using layout managers, registering listeners and writing code to handle events like button clicks.
This document provides an overview of graphical user interface (GUI) components in Java. It discusses key Swing components like JLabel, JTextField, JButton and how they work. It also explains the event-driven nature of GUIs and Java's event handling model involving event sources, listener interfaces, and event handlers. Key aspects like registering listeners on components and implementing event handling methods are demonstrated using examples of labels, text fields and buttons.
The document discusses event handling in Java. It defines key terms like events, event sources, and event listeners. Events describe changes in state of objects, like user interactions. Event sources generate events, while event listeners receive notifications of events. The delegation event model is described where sources generate events that are sent to registered listeners. Important event classes like ActionEvent and listener interfaces are listed. The steps to handle events, which include implementing listener interfaces and registering components with listeners, are outlined.
The document provides an overview of key topics in Java including event handling, the delegation event model, event classes, listener interfaces, adapter and inner classes, working with windows, graphics and text, AWT controls, layout managers, menus, Java applets, beans, and servlets. It discusses event types, how events are handled in Java using the delegation model with sources and listeners, common event classes and interfaces, and how to draw graphics and text. It also covers using various AWT components, different layout managers, creating menus, and basics of applets, beans, and servlets.
The document discusses Java event handling and the delegation event model. It describes key concepts like events, sources that generate events, and listeners that handle events. It provides examples of registering components as listeners and implementing listener interfaces. The delegation event model joins sources, listeners, and events by notifying listeners when sources generate events.
The document discusses how event listeners in Swing handle user events in Java GUI applications. It explains that classes need to implement listener interfaces to respond to specific event types. When a component is associated with a listener object, the listener will receive notifications for that event type. The listener must contain handler methods that are called when events occur. Details like the event source can be extracted from the event object passed to the handler.
ACtionlistener in java use in discussion.pptxMattFlordeliza1
The document discusses how to use the ActionListener interface in Java to handle button click events in GUI applications. ActionListener defines an actionPerformed method that is called when a button is clicked. To use ActionListener, you create a class that implements the interface and overrides actionPerformed, then register an instance of that class with the button using addActionListener. This allows executing code in response to button clicks.
The document provides information on Java AWT and JavaFX. It discusses key Java AWT components like Label, TextField, Button, TextArea, Checkbox, List, Canvas, Menu, Popup Menu, Panel, and Dialog. It also covers Java AWT layouts and listeners. For JavaFX, it describes the package, stage, scene, application class lifecycle, and common controls like Label, Button, and ComboBox. It concludes with an overview of event handling in JavaFX.
This document provides information about graphical user interfaces (GUIs) in Java. It discusses the AWT class hierarchy including important classes like Component, Container, Frame, and Panel. It covers event handling using the delegation event model and describes common listener interfaces. It also summarizes common GUI components like labels, buttons, text fields, and menus. Layout managers and concepts of applets versus applications are briefly mentioned.
1. An event describes a change in state of an object and is generated from user interaction with GUI components like buttons, mouse movement, keyboard entry etc.
2. There are two types of events - foreground events from direct user interaction and background events from system processes.
3. Event handling is the mechanism that controls how programs respond to events using event handlers (listener objects) that contain code to execute when an event occurs. The delegation event model defines how events are generated and handled in Java.
This document discusses mouse event handling in Java. It introduces event-driven programming and shows how to implement listeners to respond to mouse events like clicks and movements. It provides templates for creating mouse click listeners and mouse motion listeners, and explains how to get the mouse location from event arguments. Methods like addMouseListener and addMouseMotionListener are used to register listeners with the event manager.
This document discusses mouse event handling in Java. It introduces event-driven programming and shows how to implement listeners to respond to mouse events like clicks and movements. It provides templates for creating mouse click listeners and mouse motion listeners, and explains how to get the mouse location from event arguments. Methods like addMouseListener and addMouseMotionListener are used to register listeners with the event manager.
- The document discusses event handling in Java GUI programs.
- It explains the Java AWT event delegation model where event sources generate events that are passed to registered listener objects.
- An example program is shown where a button generates an ActionEvent when clicked, which is handled by a listener class that implements the ActionListener interface.
- The AWT event hierarchy and common event types like KeyEvents and MouseEvents are described. Individual events provide information about user input.
- Adapter classes are mentioned which provide default empty implementations of listener interfaces to simplify coding listeners.
The document discusses event handling and layouts in Java. It describes what events are, the delegation event model used in Java for handling events, and common event and listener classes. It also provides examples of using buttons and event handling in both AWT and Swing. The section about layouts states that layout managers automatically position and size components within containers.
Java Programming :Event Handling(Types of Events)simmis5
Event Handling is the mechanism that controls the event and decides what should happen if an event occurs. This mechanism have the code which is known as event handler that is executed when an event occurs. Java Uses the Delegation Event Model to handle the events.
1. Java AWT event handling involves event sources, event classes, and event listeners.
2. Event sources are AWT components like buttons and text fields that can generate events.
3. Event classes represent the specific events generated by sources, like ActionEvent for buttons.
4. Event listeners handle the events generated by sources. Listeners implement interfaces that correspond to specific event classes.
The document discusses messaging and internationalization. It covers messaging using Java Message Service (JMS), including the need for messaging, messaging architecture, types of messaging, messaging models, messaging servers, components of a JMS application, developing effective messaging solutions, and implementing JMS. It also discusses internationalizing J2EE applications.
The document discusses Java 2 Enterprise Edition (J2EE) application security. It covers security threat assessment, the Java 2 security model, and Java security APIs. The Java 2 security model provides access controls and allows downloading and running applications securely. It uses techniques like cryptography, digital signatures, and SSL. The Java Cryptography Extensions API provides methods for encrypting data, generating keys, and authentication.
The document discusses various security tools in Java including keytool, jarsigner, and policytool. Keytool is used to manage keystores containing private keys and certificates. It can generate key pairs, import/export certificates, and list keystore contents. Jarsigner signs JAR files using certificates from a keystore. Policytool creates and edits security policy files specifying user permissions. The document provides details on using each tool's commands and options.
This document discusses EJB technology and provides summaries of key concepts:
1. It defines the EJB container model and describes features like security, distributed access, and lifecycle management.
2. It compares the lifecycles of stateless session beans, stateful session beans, entity beans, and message-driven beans.
3. It contrasts stateful and stateless session beans and discusses differences in client state, pooling, lifecycles, and more. It also compares session beans and entity beans in terms of representing processes versus data.
This document discusses behavioral design patterns and J2EE design patterns. It provides descriptions and class diagrams for several behavioral patterns, including Iterator, Mediator, Memento, Observer, State, Strategy, Template Method, and Visitor. It also defines what a J2EE design pattern is and notes that J2EE patterns are categorized into the presentation, business, and integration tiers of an enterprise application.
This document provides an overview of EJB in J2EE architecture and EJB design patterns. It discusses the key characteristics of using EJB in J2EE architecture, including supporting multiple clients, improving reliability and productivity, supporting large scale deployment, developing transactional applications, and implementing security. It also outlines several EJB design patterns, such as client-side interaction patterns, EJB layer architectural patterns, inter-tier data transfer patterns, and transaction/persistence patterns.
This document discusses design patterns and provides examples of structural and behavioral design patterns. It describes the adapter, bridge, composite, decorator, facade, flyweight, proxy, chain of responsibility, and command patterns. Structural patterns are concerned with relationships and responsibilities between objects, while behavioral patterns focus on communication between objects. Examples of UML diagrams are provided to illustrate how each pattern can be modeled.
The document discusses UML diagrams that can be used to model J2EE applications, including use case diagrams, class diagrams, package diagrams, sequence diagrams, collaboration diagrams, state diagrams, activity diagrams, component diagrams, and deployment diagrams. It provides examples of each diagram type using a case study of an online bookstore system. The use case diagram shows use cases and actors, the class diagram shows classes and relationships, and other diagrams demonstrate how specific interactions, workflows, and system configurations can be modeled through different UML diagrams.
This document discusses design patterns and selecting appropriate patterns based on business requirements. It provides an overview of design patterns available in TheServerSide.com pattern catalog, which are organized into categories like EJB layer architectural patterns, inter-tier data transfer patterns, transaction and persistence patterns, and client-side EJB interaction patterns. Examples of patterns in each category are described. Best practices for developing class diagrams and using proven design patterns are also mentioned.
This document provides an overview of J2EE architecture. It defines architecture as the study of designing J2EE applications and discusses architectural concepts like attributes, models, and terminology. It describes the role of an architect and phases of architectural design. The document outlines the various components of J2EE like clients, web components, business components and containers. It also discusses key aspects of J2EE architecture like application areas, issues, technologies and available application servers.
The document discusses various topics related to collaboration and distributed systems including network communication in distributed environments, application integration using XML, and legacy integration technologies. Specifically, it covers factors that affect network performance like bandwidth and latency. It also describes using XML for data mapping between applications and data stores. Finally, it discusses different legacy integration methods like screen scraping, object mapping tools, and using off-board servers.
The document discusses JavaBean properties, property editors, and the classes used to implement them in Java. It describes the PropertyEditorSupport class and its methods for creating customized property editors. The PropertyDescriptor class and BeanInfo interface provide information about JavaBean properties, events, and methods. The document also provides tips on using sample JavaBeans from BDK1.1 in Java 2 SDK and creating a manifest file for multiple JavaBeans. Common questions about JavaBeans are answered.
The document discusses JavaBean properties and custom events. It defines different types of JavaBean properties like simple, boolean, indexed, bound, and constrained properties. It also explains how to create custom events by defining an event class, event listener interface, and event handler. The event handler notifies listeners when an event occurs. Finally, it demonstrates creating a login JavaBean that uses a custom event to validate that a username and password are not the same.
The document introduces JavaBeans, which are reusable software components created using Java. It discusses JavaBean concepts like properties, methods, and events. It also describes the Beans Development Kit (BDK) environment for creating, configuring, and testing JavaBeans. BDK includes components like the ToolBox, BeanBox, Properties window, and Method Tracer window. The document provides demonstrations of creating a sample JavaBean applet and user-defined JavaBean using BDK. It also covers topics like creating manifest and JAR files for packaging JavaBeans.
The document provides information on working with joins, the JDBC API, and isolation levels in Java database applications. It discusses different types of joins like inner joins, cross joins, and outer joins. It describes the key interfaces in the JDBC API like Statement, PreparedStatement, ResultSet, Connection, and DatabaseMetaData. It also covers isolation levels and how they prevent issues with concurrently running transactions accessing a database.
The document discusses various advanced features of JDBC including using prepared statements, managing transactions, performing batch updates, and calling stored procedures. Prepared statements improve performance by compiling SQL statements only once. Transactions allow grouping statements to execute atomically through commit and rollback. Batch updates reduce network calls by executing multiple statements as a single unit. Stored procedures are called using a CallableStatement object which can accept input parameters and return output parameters.
The document introduces JDBC and its key concepts. It discusses the JDBC architecture with two layers - the application layer and driver layer. It describes the four types of JDBC drivers and how they work. The document outlines the classes and interfaces that make up the JDBC API and the basic steps to create a JDBC application, including loading a driver, connecting to a database, executing statements, and handling exceptions. It provides examples of using JDBC to perform common database operations like querying, inserting, updating, and deleting data.
The document discusses classes and objects in Java, including defining classes with data members and methods, creating objects, using constructors, and the structure of a Java application. It also covers access specifiers, modifiers, compiling Java files, and provides a summary of key points about classes and objects in Java.
The document discusses casting and conversion in Java. It covers implicit and explicit type conversions, including widening, narrowing, and casting conversions. It also discusses overloading constructors in Java by defining multiple constructor methods with the same name but different parameters. The document provides examples of casting integer and double values to byte type, as well as overloading the Cuboid constructor to calculate volumes for rectangles and squares.
The document discusses operators in Java, including unary, binary, arithmetic, bitwise, shift, and instanceof operators. It provides examples of how to use various operators like increment, decrement, arithmetic assignment, bitwise AND, OR, NOT, XOR, right shift, left shift, and unsigned shift. It also covers operator precedence and demonstrates how operators in an expression are evaluated based on their predetermined precedence order.
"Frontline Battles with DDoS: Best practices and Lessons Learned", Igor IvaniukFwdays
At this talk we will discuss DDoS protection tools and best practices, discuss network architectures and what AWS has to offer. Also, we will look into one of the largest DDoS attacks on Ukrainian infrastructure that happened in February 2022. We'll see, what techniques helped to keep the web resources available for Ukrainians and how AWS improved DDoS protection for all customers based on Ukraine experience
"Choosing proper type of scaling", Olena SyrotaFwdays
Imagine an IoT processing system that is already quite mature and production-ready and for which client coverage is growing and scaling and performance aspects are life and death questions. The system has Redis, MongoDB, and stream processing based on ksqldb. In this talk, firstly, we will analyze scaling approaches and then select the proper ones for our system.
The Microsoft 365 Migration Tutorial For Beginner.pptxoperationspcvita
This presentation will help you understand the power of Microsoft 365. However, we have mentioned every productivity app included in Office 365. Additionally, we have suggested the migration situation related to Office 365 and how we can help you.
You can also read: https://www.systoolsgroup.com/updates/office-365-tenant-to-tenant-migration-step-by-step-complete-guide/
High performance Serverless Java on AWS- GoTo Amsterdam 2024Vadym Kazulkin
Java is for many years one of the most popular programming languages, but it used to have hard times in the Serverless community. Java is known for its high cold start times and high memory footprint, comparing to other programming languages like Node.js and Python. In this talk I'll look at the general best practices and techniques we can use to decrease memory consumption, cold start times for Java Serverless development on AWS including GraalVM (Native Image) and AWS own offering SnapStart based on Firecracker microVM snapshot and restore and CRaC (Coordinated Restore at Checkpoint) runtime hooks. I'll also provide a lot of benchmarking on Lambda functions trying out various deployment package sizes, Lambda memory settings, Java compilation options and HTTP (a)synchronous clients and measure their impact on cold and warm start times.
In the realm of cybersecurity, offensive security practices act as a critical shield. By simulating real-world attacks in a controlled environment, these techniques expose vulnerabilities before malicious actors can exploit them. This proactive approach allows manufacturers to identify and fix weaknesses, significantly enhancing system security.
This presentation delves into the development of a system designed to mimic Galileo's Open Service signal using software-defined radio (SDR) technology. We'll begin with a foundational overview of both Global Navigation Satellite Systems (GNSS) and the intricacies of digital signal processing.
The presentation culminates in a live demonstration. We'll showcase the manipulation of Galileo's Open Service pilot signal, simulating an attack on various software and hardware systems. This practical demonstration serves to highlight the potential consequences of unaddressed vulnerabilities, emphasizing the importance of offensive security practices in safeguarding critical infrastructure.
What is an RPA CoE? Session 2 – CoE RolesDianaGray10
In this session, we will review the players involved in the CoE and how each role impacts opportunities.
Topics covered:
• What roles are essential?
• What place in the automation journey does each role play?
Speaker:
Chris Bolin, Senior Intelligent Automation Architect Anika Systems
Conversational agents, or chatbots, are increasingly used to access all sorts of services using natural language. While open-domain chatbots - like ChatGPT - can converse on any topic, task-oriented chatbots - the focus of this paper - are designed for specific tasks, like booking a flight, obtaining customer support, or setting an appointment. Like any other software, task-oriented chatbots need to be properly tested, usually by defining and executing test scenarios (i.e., sequences of user-chatbot interactions). However, there is currently a lack of methods to quantify the completeness and strength of such test scenarios, which can lead to low-quality tests, and hence to buggy chatbots.
To fill this gap, we propose adapting mutation testing (MuT) for task-oriented chatbots. To this end, we introduce a set of mutation operators that emulate faults in chatbot designs, an architecture that enables MuT on chatbots built using heterogeneous technologies, and a practical realisation as an Eclipse plugin. Moreover, we evaluate the applicability, effectiveness and efficiency of our approach on open-source chatbots, with promising results.
inQuba Webinar Mastering Customer Journey Management with Dr Graham HillLizaNolte
HERE IS YOUR WEBINAR CONTENT! 'Mastering Customer Journey Management with Dr. Graham Hill'. We hope you find the webinar recording both insightful and enjoyable.
In this webinar, we explored essential aspects of Customer Journey Management and personalization. Here’s a summary of the key insights and topics discussed:
Key Takeaways:
Understanding the Customer Journey: Dr. Hill emphasized the importance of mapping and understanding the complete customer journey to identify touchpoints and opportunities for improvement.
Personalization Strategies: We discussed how to leverage data and insights to create personalized experiences that resonate with customers.
Technology Integration: Insights were shared on how inQuba’s advanced technology can streamline customer interactions and drive operational efficiency.
Must Know Postgres Extension for DBA and Developer during MigrationMydbops
Mydbops Opensource Database Meetup 16
Topic: Must-Know PostgreSQL Extensions for Developers and DBAs During Migration
Speaker: Deepak Mahto, Founder of DataCloudGaze Consulting
Date & Time: 8th June | 10 AM - 1 PM IST
Venue: Bangalore International Centre, Bangalore
Abstract: Discover how PostgreSQL extensions can be your secret weapon! This talk explores how key extensions enhance database capabilities and streamline the migration process for users moving from other relational databases like Oracle.
Key Takeaways:
* Learn about crucial extensions like oracle_fdw, pgtt, and pg_audit that ease migration complexities.
* Gain valuable strategies for implementing these extensions in PostgreSQL to achieve license freedom.
* Discover how these key extensions can empower both developers and DBAs during the migration process.
* Don't miss this chance to gain practical knowledge from an industry expert and stay updated on the latest open-source database trends.
Mydbops Managed Services specializes in taking the pain out of database management while optimizing performance. Since 2015, we have been providing top-notch support and assistance for the top three open-source databases: MySQL, MongoDB, and PostgreSQL.
Our team offers a wide range of services, including assistance, support, consulting, 24/7 operations, and expertise in all relevant technologies. We help organizations improve their database's performance, scalability, efficiency, and availability.
Contact us: info@mydbops.com
Visit: https://www.mydbops.com/
Follow us on LinkedIn: https://in.linkedin.com/company/mydbops
For more details and updates, please follow up the below links.
Meetup Page : https://www.meetup.com/mydbops-databa...
Twitter: https://twitter.com/mydbopsofficial
Blogs: https://www.mydbops.com/blog/
Facebook(Meta): https://www.facebook.com/mydbops/
What is an RPA CoE? Session 1 – CoE VisionDianaGray10
In the first session, we will review the organization's vision and how this has an impact on the COE Structure.
Topics covered:
• The role of a steering committee
• How do the organization’s priorities determine CoE Structure?
Speaker:
Chris Bolin, Senior Intelligent Automation Architect Anika Systems
For the full video of this presentation, please visit: https://www.edge-ai-vision.com/2024/06/temporal-event-neural-networks-a-more-efficient-alternative-to-the-transformer-a-presentation-from-brainchip/
Chris Jones, Director of Product Management at BrainChip , presents the “Temporal Event Neural Networks: A More Efficient Alternative to the Transformer” tutorial at the May 2024 Embedded Vision Summit.
The expansion of AI services necessitates enhanced computational capabilities on edge devices. Temporal Event Neural Networks (TENNs), developed by BrainChip, represent a novel and highly efficient state-space network. TENNs demonstrate exceptional proficiency in handling multi-dimensional streaming data, facilitating advancements in object detection, action recognition, speech enhancement and language model/sequence generation. Through the utilization of polynomial-based continuous convolutions, TENNs streamline models, expedite training processes and significantly diminish memory requirements, achieving notable reductions of up to 50x in parameters and 5,000x in energy consumption compared to prevailing methodologies like transformers.
Integration with BrainChip’s Akida neuromorphic hardware IP further enhances TENNs’ capabilities, enabling the realization of highly capable, portable and passively cooled edge devices. This presentation delves into the technical innovations underlying TENNs, presents real-world benchmarks, and elucidates how this cutting-edge approach is positioned to revolutionize edge AI across diverse applications.
Northern Engraving | Nameplate Manufacturing Process - 2024Northern Engraving
Manufacturing custom quality metal nameplates and badges involves several standard operations. Processes include sheet prep, lithography, screening, coating, punch press and inspection. All decoration is completed in the flat sheet with adhesive and tooling operations following. The possibilities for creating unique durable nameplates are endless. How will you create your brand identity? We can help!
LF Energy Webinar: Carbon Data Specifications: Mechanisms to Improve Data Acc...DanBrown980551
This LF Energy webinar took place June 20, 2024. It featured:
-Alex Thornton, LF Energy
-Hallie Cramer, Google
-Daniel Roesler, UtilityAPI
-Henry Richardson, WattTime
In response to the urgency and scale required to effectively address climate change, open source solutions offer significant potential for driving innovation and progress. Currently, there is a growing demand for standardization and interoperability in energy data and modeling. Open source standards and specifications within the energy sector can also alleviate challenges associated with data fragmentation, transparency, and accessibility. At the same time, it is crucial to consider privacy and security concerns throughout the development of open source platforms.
This webinar will delve into the motivations behind establishing LF Energy’s Carbon Data Specification Consortium. It will provide an overview of the draft specifications and the ongoing progress made by the respective working groups.
Three primary specifications will be discussed:
-Discovery and client registration, emphasizing transparent processes and secure and private access
-Customer data, centering around customer tariffs, bills, energy usage, and full consumption disclosure
-Power systems data, focusing on grid data, inclusive of transmission and distribution networks, generation, intergrid power flows, and market settlement data
Introduction of Cybersecurity with OSS at Code Europe 2024Hiroshi SHIBATA
I develop the Ruby programming language, RubyGems, and Bundler, which are package managers for Ruby. Today, I will introduce how to enhance the security of your application using open-source software (OSS) examples from Ruby and RubyGems.
The first topic is CVE (Common Vulnerabilities and Exposures). I have published CVEs many times. But what exactly is a CVE? I'll provide a basic understanding of CVEs and explain how to detect and handle vulnerabilities in OSS.
Next, let's discuss package managers. Package managers play a critical role in the OSS ecosystem. I'll explain how to manage library dependencies in your application.
I'll share insights into how the Ruby and RubyGems core team works to keep our ecosystem safe. By the end of this talk, you'll have a better understanding of how to safeguard your code.
AppSec PNW: Android and iOS Application Security with MobSFAjin Abraham
Mobile Security Framework - MobSF is a free and open source automated mobile application security testing environment designed to help security engineers, researchers, developers, and penetration testers to identify security vulnerabilities, malicious behaviours and privacy concerns in mobile applications using static and dynamic analysis. It supports all the popular mobile application binaries and source code formats built for Android and iOS devices. In addition to automated security assessment, it also offers an interactive testing environment to build and execute scenario based test/fuzz cases against the application.
This talk covers:
Using MobSF for static analysis of mobile applications.
Interactive dynamic security assessment of Android and iOS applications.
Solving Mobile app CTF challenges.
Reverse engineering and runtime analysis of Mobile malware.
How to shift left and integrate MobSF/mobsfscan SAST and DAST in your build pipeline.
The Department of Veteran Affairs (VA) invited Taylor Paschal, Knowledge & Information Management Consultant at Enterprise Knowledge, to speak at a Knowledge Management Lunch and Learn hosted on June 12, 2024. All Office of Administration staff were invited to attend and received professional development credit for participating in the voluntary event.
The objectives of the Lunch and Learn presentation were to:
- Review what KM ‘is’ and ‘isn’t’
- Understand the value of KM and the benefits of engaging
- Define and reflect on your “what’s in it for me?”
- Share actionable ways you can participate in Knowledge - - Capture & Transfer
1. Java Programming Language
Objectives
In this session, you will learn to:
Define events and event handling
Determine the user action that originated the event from the
event object details
Identify the appropriate listener interface for a variety of event
types
Create the appropriate event handler methods for a variety of
event types
Understand the use of inner classes and anonymous classes in
event handling
Identify the key AWT components and the events they trigger
Describe how to create menu, menu bar, menu items and how
to control visual aspects
Ver. 1.0 Session 11 Slide 1 of 26
2. Java Programming Language
Events
Events: Objects that describe what happened
Event sources: The generator of an event
Event handlers: A method that receives an event object,
deciphers it, and processes the user’s interaction.
Ver. 1.0 Session 11 Slide 2 of 26
3. Java Programming Language
Delegation Model of Event
An event can be sent to many event handlers.
Event handlers register with components when they are
interested in events generated by that component.
Ver. 1.0 Session 11 Slide 3 of 26
4. Java Programming Language
Delegation Model of Event (Contd.)
Client objects (handlers) register with a GUI component that
they want to observe.
GUI components only trigger the handlers for the type of
event that has occurred.
Most components can trigger more than one type of event.
The delegation model distributes the work among multiple
classes.
Ver. 1.0 Session 11 Slide 4 of 26
5. Java Programming Language
A Listener Example
This code snippet shows a simple Frame with a single
button on it, class name is TestButton:
public TestButton()
{
f = new Frame("Test");
b = new Button("Press Me!");
b.setActionCommand("ButtonPressed");
}
public void launchFrame()
{
b.addActionListener(new ButtonHandler());
f.add(b,BorderLayout.CENTER);
f.pack();
f.setVisible(true);
}
Ver. 1.0 Session 11 Slide 5 of 26
6. Java Programming Language
A Listener Example (Contd.)
Code for the event listener looks like this:
import java.awt.event.*;
public class ButtonHandler implements
ActionListener
{
public void actionPerformed(ActionEvent e)
{
System.out.println("Action occurred");
System.out.println("Button’s command is:
"+ e.getActionCommand());
}
}
The event is delegated to ButtonHandler class.
Ver. 1.0 Session 11 Slide 6 of 26
9. Java Programming Language
Listener Type
Some Events and Their Associated Event Listeners:
Act that Results in the Event Listener Type
User clicks a button, presses Enter while typing
ActionListener
in a text field, or chooses a menu item
User closes a frame (main window) WindowListener
User presses a mouse button while the cursor is
MouseListener
over a component
User moves the mouse over a component MouseMotionListener
Component becomes visible ComponentListener
Component gets the keyboard focus FocusListener
Ver. 1.0 Session 11 Slide 9 of 26
10. Java Programming Language
Listeners
ActionListener Interface:
– Has only one method i.e.
actionPerformed(ActionEvent)
– To detect when the user clicks an onscreen button (or does the
keyboard equivalent), a program must have an object that
implements the ActionListener interface.
– The program must register this object as an action listener on
the button (the event source), using the
addActionListener() method.
– When the user clicks the onscreen button, the button fires an
action event.
Ver. 1.0 Session 11 Slide 10 of 26
11. Java Programming Language
Listeners (Contd.)
MouseListener interface:
– To detect the mouse clicking, a program must have an object
that implements the MouseListener interface.
– This interface includes several events including
mouseEntered, mouseExited, mousePressed,
mouseReleased, and mouseClicked.
– When the user clicks the onscreen button, the button fires an
action event.
Ver. 1.0 Session 11 Slide 11 of 26
12. Java Programming Language
Listeners (Contd.)
Implementing Multiple Interfaces:
A class can be declared with Multiple Interfaces by using
comma separation:
• Implements MouseListener,MouseMotionListener
Listening to Multiple Sources:
Multiple listeners cause unrelated parts of a program to react
to the same event.
The handlers of all registered listeners are called when the
event occurs.
Ver. 1.0 Session 11 Slide 12 of 26
13. Java Programming Language
Event Adapters
The listener classes that you define can extend adapter
classes and override only the methods that you need.
An example is:
import java.awt.*;
import java.awt.event.*;
public class MouseClickHandler extends
MouseAdapter
{
//We just need the mouseClick handler,
so //we use an adapter to avoid having
to //write all the event handler methods
Ver. 1.0 Session 11 Slide 13 of 26
14. Java Programming Language
Event Adapters (Contd.)
public void mouseClicked(MouseEvent e)
{
// Do stuff with the mouse click...
}
}
Ver. 1.0 Session 11 Slide 14 of 26
15. Java Programming Language
Inner Classes
Event Handling Using Inner Classes:
Using inner classes for event handles gives access to the
private data of the outer class.
Ver. 1.0 Session 11 Slide 15 of 26
16. Java Programming Language
MenuBar
Frames can contain a menu bar, a menu bar can contain
zero or more menus, and menu can contain zero or more
menu items (including submenus).
Let’s see how to do this.
Ver. 1.0 Session 11 Slide 16 of 26
17. Java Programming Language
Creating a MenuBar
Create a MenuBar object, and set it into a menu container,
such as a Frame. For example:
Frame f = new Frame("MenuBar");
MenuBar mb = new MenuBar();
f.setMenuBar(mb);
Ver. 1.0 Session 11 Slide 17 of 26
18. Java Programming Language
Creating a Menu
Create one or more Menu objects, and add them to the
menu bar object. For example:
Frame f = new Frame("Menu");
MenuBar mb = new MenuBar();
Menu m1 = new Menu("File");
Menu m2 = new Menu("Edit");
Menu m3 = new Menu("Help");
mb.add(m1);
mb.add(m2);
mb.setHelpMenu(m3);
f.setMenuBar(mb);
Ver. 1.0 Session 11 Slide 18 of 26
19. Java Programming Language
Creating a MenuItem
Create one or more MenuItem objects, and add them to the
menu object. For example:
MenuItem mi1 = new MenuItem("New");
MenuItem mi2 = new MenuItem("Save");
MenuItem mi3 = new MenuItem("Load");
MenuItem mi4 = new MenuItem("Quit");
mi1.addActionListener(this);
mi2.addActionListener(this);
mi3.addActionListener(this);
mi4.addActionListener(this);
m1.add(mi1);
m1.add(mi2);
Ver. 1.0 Session 11 Slide 19 of 26
20. Java Programming Language
Creating a MenuItem (Contd.)
m1.add(mi3);
m1.addSeparator();
m1.add(mi4);
Let’ see how MenuItem will look like.
Ver. 1.0 Session 11 Slide 20 of 26
22. Java Programming Language
Creating a CheckBoxMenuItem
Creating a CheckBoxMenuItem:
CheckboxMenuItem mi5 =
newCheckboxMenuItem("Persistent");
mi5.addItemListener(this);
m1.add(mi5);
Ver. 1.0 Session 11 Slide 22 of 26
23. Java Programming Language
Controlling Visual Aspects
Commands to control visual aspects of the GUI include:
Colors:
setForeground()
setBackground()
Example:
Color purple = new Color(255, 0, 255);
Button b = new Button(“Purple”);
b.setBackground(purple);
Ver. 1.0 Session 11 Slide 23 of 26
24. Java Programming Language
J.F.C./Swing Technology
• Java Foundation Class/Swing (J.F.C./Swing) technology is
a second-generation GUI toolkit.
• It builds on top of AWT, but supplants the components with
lightweight versions.
• There are many more components, and much more
complex components, including JTable, JTree, and
JComboBox.
Ver. 1.0 Session 11 Slide 24 of 26
25. Java Programming Language
Summary
In this session, you learned that:
When user perform some action, for example, button click or
mouse move then the program performs some action which is
called event.
Events can be handled by implementing appropriate Listener
Interface.
Most components can trigger more than one type of event.
The delegation model distributes the work among multiple
classes.
ActionListener Interface:
• When the user clicks an onscreen button (or does the keyboard
equivalent), a program must have an object that implements the
ActionListener interface.
MouseListener Interface:
• To detect the mouse clicking, a program must have an object that
implements the MouseListener interface.
Ver. 1.0 Session 11 Slide 25 of 26
26. Java Programming Language
Summary (Contd.)
– A class can be declared with multiple interfaces by using
comma separation.
– Event Adapter classes can be used in place of implementing
listener, if you need to implement only one method.
– Manubar can be created by creating a MenuBar class object,
and set it into a menu container, such as a Frame.
– Menu class object is used to create menu, and add them to the
MenuBar object.
– MenuItems can be created by creating one or more MenuItem
class objects, and add them to the menu object.
– Checked menuitems can be created by using
CheckboxMenuItem class object.
– Colors can be set by creating the Color class object.
Ver. 1.0 Session 11 Slide 26 of 26