This document discusses different strategies for handling mouse and keyboard events in Java programs. It describes registering listener objects to handle events from GUI components and defines the standard AWT listener types. The strategies covered include using separate listener classes, implementing listener interfaces, and defining named and anonymous inner classes. Examples are provided to illustrate drawing on mouse clicks and key presses.
This document discusses user input handling in libGDX, including event vs polling, touch and keyboard input, accelerometer input, gestures, and text input. It provides code examples for setting up input processors and listeners to handle different types of input in libGDX, including touch, keyboard, accelerometer, and gesture events. It also covers vibration and compass input.
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 LibGDX's support for internationalization and scene 2D.
It describes how to create property files for different languages to support internationalization in LibGDX games. It then provides an overview of Scene2D, describing it as an optional higher-level framework for creating 2D games and UIs using stages, actors, and events. It includes code examples of creating a stage and adding an actor, as well as handling input events with actors.
Creating Asha Games: Game Pausing, Orientation, Sensors and GesturesJussi Pohjolainen
This document discusses various techniques for creating games in Asha OS, including game pausing, handling device orientation changes, using mobile sensors, and gestures. It covers pausing a game when the phone rings or the back button is pressed using showNotify() and hideNotify() methods. It also discusses setting the UI orientation, getting sensor data, and handling threading and synchronization for pausing the game loop.
- 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.
Event handling involves responding to user actions like clicking buttons or typing text. Events are generated by sources like buttons or keyboards and handled by listeners that implement specific event listener interfaces. The listener is registered with the source to receive notifications when events occur, then processes the event by implementing callback methods defined in the listener interface. Common types of events include action events, item events, and mouse events.
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 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.
This document discusses user input handling in libGDX, including event vs polling, touch and keyboard input, accelerometer input, gestures, and text input. It provides code examples for setting up input processors and listeners to handle different types of input in libGDX, including touch, keyboard, accelerometer, and gesture events. It also covers vibration and compass input.
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 LibGDX's support for internationalization and scene 2D.
It describes how to create property files for different languages to support internationalization in LibGDX games. It then provides an overview of Scene2D, describing it as an optional higher-level framework for creating 2D games and UIs using stages, actors, and events. It includes code examples of creating a stage and adding an actor, as well as handling input events with actors.
Creating Asha Games: Game Pausing, Orientation, Sensors and GesturesJussi Pohjolainen
This document discusses various techniques for creating games in Asha OS, including game pausing, handling device orientation changes, using mobile sensors, and gestures. It covers pausing a game when the phone rings or the back button is pressed using showNotify() and hideNotify() methods. It also discusses setting the UI orientation, getting sensor data, and handling threading and synchronization for pausing the game loop.
- 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.
Event handling involves responding to user actions like clicking buttons or typing text. Events are generated by sources like buttons or keyboards and handled by listeners that implement specific event listener interfaces. The listener is registered with the source to receive notifications when events occur, then processes the event by implementing callback methods defined in the listener interface. Common types of events include action events, item events, and mouse events.
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 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.
A split screen-viable UI event system - Unite Copenhagen 2019Unity Technologies
Learn about the implementation of a 2-player split-screen user interface (UI) in Battle Planet Judgement Day. In Unity, the Event System allows only one element to be currently selected, which can be a problem when designing split screen UI. In this session, you'll discover how this issue was addressed in Battle Planet Judgement Day, the ups and downs of the implementation, insights on pitfalls to avoid and best practices learned during the time of development. We hope this will help you learn how to implement your own solution.
Speaker: Kevin Hagen - Threaks
Session available here: https://youtu.be/aR5UXatawmE
Do you have a need for custom components or behavior? This session will bring you the knowledge you require to create and extend custom components. Learn which calls to intercept for your custom logic.
This document provides an overview of event handling in Java. It discusses key concepts like events, event sources, event listeners, and different types of events like action events, item events, key events, mouse events, and window events. For each event type, it describes the relevant listener interface and event class, including their common methods. It explains how events are generated by sources and handled by registered listener objects using the delegation event model in Java.
This document provides instructions for creating a top-down space shooter game in Unity. It includes setting up the player ship object with movement controls, firing bullets, creating lighting and a background, and destroying bullets when they exit the boundary. Key steps are importing a space shooter tutorial package, adding scripts to control ship movement and firing, spawning bullet prefabs, and destroying bullets using a trigger collider on the boundary object.
This document summarizes a presentation about the Unity game development platform. It introduces Unity as a game engine that integrates tools for creating 3D and 2D content across platforms. It describes Unity's main components, including the game engine, editor tools, asset store, and support for multiple platforms. It provides screenshots explaining Unity's interface and gives examples of creating a simple space shooter game in Unity, including importing assets, scripting enemy behavior, using prefabs, and adding collisions and a game over scene.
The document discusses GUI event handling in Java. It explains that window-based Java programs are event-driven, meaning they wait for and respond to user-initiated events like button clicks or key presses. When an event occurs, an event object is passed to a listener object that handles the event. Listeners implement interfaces that correspond to different event types, like ActionListener for button clicks. The delegation event model in Java handles event passing from components to listeners.
This document provides an introduction and overview of the Java Swing GUI toolkit. It discusses what Swing is, its main characteristics including being platform independent, customizable, extensible and lightweight. It explains that Swing is written entirely in Java and is part of the Java Foundation Classes. The document also provides examples of simple first programs using Swing including creating a basic window, centering a window, adding buttons and tooltips. It demonstrates creating menus and toolbars and includes examples of submenus and checkbox menu items.
This document provides a tutorial on using the accelerometer sensor in Android applications. It discusses retrieving the accelerometer sensor from the SensorManager, registering a listener, and handling sensor events to detect phone movements like shaking. Code examples are given for an AccelerometerListener interface, AccelerometerManager class to manage sensor access, and an Activity that implements the listener to detect shakes and log accelerometer data.
.NET Gadgeteer is a new toolkit for quickly constructing, programming and shaping new small computing devices (gadgets)
Ideal for teaching computer science, engineering, Design and Technology in schools, colleges and universities more details here http://www.netmf.com/gadgeteer/
Session 12 - Overview of taps, multitouch, and gestures Vu Tran Lam
This document provides an overview of gesture recognition and touch handling in iOS application development. It discusses the responder chain and how touch events are delivered. It also covers creating subclasses of UIResponder to handle touch events, recognizing common gestures like taps, swipes, and pinches, and using gesture recognizers to simplify touch handling. Gesture recognizers can be used to detect gestures and trigger actions in response.
Building a turn-based game prototype using ECS - Unite Copenhagen 2019Unity Technologies
Get a high-level overview of the Entity Component System (ECS) and turn-based game loops, and see a proof of concept built using ECS. These slides will cover some of the pitfalls and also show concepts of ECS in a slightly exotic context.
Speaker:
Florian Uhde - Three Eyed Games
Watch the session on YouTube: https://youtu.be/mL4qrt-15TE
The document discusses Java AWT event handling. It describes how AWT components generate events that are passed to listener objects. It provides examples of common event classes like ActionEvent and MouseEvent, and the interfaces that listener objects must implement like ActionListener and MouseListener. It also gives a simple example of an applet that registers listeners on different components and handles events in the listener methods.
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 outlines the syllabus for an Object Oriented Programming using C++ course. It is divided into 3 sections - Introduction to OOP concepts and C++ basics, Classes and Objects, and Input/Output files. Section I covers OOP characteristics, C++ program statements, functions, arrays and pointers. Section II covers classes, objects, inheritance, polymorphism and static/friend functions. Section III discusses file I/O using streams in C++. The question paper for internal assessment will have 2 parts - short questions from each section in Part A and longer questions covering all sections in Part B.
This document provides instructions for various laboratory animal handling techniques in mice, including blood collection from the tail vein, orbital sinus, and by cardiac puncture. It also describes how to perform intraperitoneal and subcutaneous injections, oral feeding, and sexing of mice. The techniques are explained step-by-step and include lists of the necessary tools and materials to perform each procedure properly to avoid mishandling animals and comply with welfare regulations.
This document discusses file handling in C++. It begins by explaining that files allow data to be stored permanently on secondary storage devices like hard disks, unlike variables in memory. It then covers key topics like:
- The different types of files, such as text files containing readable characters and binary files containing raw data.
- Classes used for file input/output like ifstream, ofstream, and fstream.
- Opening, closing, reading from, and writing to files using functions like open(), close(), get(), put(), seekg(), tellg(), seekp(), and tellp().
- File pointers that track read/write positions and functions to manipulate them.
- Examples of creating
The document discusses file input and output in Java. It covers using the File class to get information about files, using JFileChooser to select files, and different streams for reading and writing files including FileInputStream, FileOutputStream, DataInputStream, DataOutputStream, FileWriter, PrintWriter, FileReader and BufferedReader. It provides examples of using these classes and methods to write bytes, primitive data types and text to files and read them back.
This document discusses different types of arrays in C#, including simple arrays, multidimensional arrays, jagged arrays, and tuples. Simple arrays store elements of the same type and can be initialized with syntax like "datatype[] myArray = new datatype[size]". Multidimensional arrays are indexed by two or more integers. Jagged arrays allow each row to have a different size. Tuples were introduced in .NET 4.0 and act as a way to group multiple data types together.
This chapter discusses various methods of file input and output in Java, including low-level file I/O using FileInputStream and FileOutputStream, high-level file I/O using DataInputStream and DataOutputStream to read and write primitive data types, reading and writing text files using PrintWriter, BufferedReader, and Scanner, and object file I/O using ObjectInputStream and ObjectOutputStream to save and load objects. It also covers using JFileChooser to allow users to select files and applying file filters.
This document discusses different strategies for handling mouse and keyboard events in Java applications, including using separate listener classes, implementing listener interfaces, and defining inner listener classes. It provides examples of drawing shapes in response to mouse clicks and keyboard input. It also summarizes the standard AWT listener types and their corresponding methods.
This document discusses GUI event handling in Java. It introduces the delegation event model where event sources generate event objects that are passed to registered event listeners. It covers common event classes and listener interfaces like ActionListener, MouseListener, and WindowListener. It provides examples of handling mouse and window events using different approaches like inner classes and anonymous inner classes.
A split screen-viable UI event system - Unite Copenhagen 2019Unity Technologies
Learn about the implementation of a 2-player split-screen user interface (UI) in Battle Planet Judgement Day. In Unity, the Event System allows only one element to be currently selected, which can be a problem when designing split screen UI. In this session, you'll discover how this issue was addressed in Battle Planet Judgement Day, the ups and downs of the implementation, insights on pitfalls to avoid and best practices learned during the time of development. We hope this will help you learn how to implement your own solution.
Speaker: Kevin Hagen - Threaks
Session available here: https://youtu.be/aR5UXatawmE
Do you have a need for custom components or behavior? This session will bring you the knowledge you require to create and extend custom components. Learn which calls to intercept for your custom logic.
This document provides an overview of event handling in Java. It discusses key concepts like events, event sources, event listeners, and different types of events like action events, item events, key events, mouse events, and window events. For each event type, it describes the relevant listener interface and event class, including their common methods. It explains how events are generated by sources and handled by registered listener objects using the delegation event model in Java.
This document provides instructions for creating a top-down space shooter game in Unity. It includes setting up the player ship object with movement controls, firing bullets, creating lighting and a background, and destroying bullets when they exit the boundary. Key steps are importing a space shooter tutorial package, adding scripts to control ship movement and firing, spawning bullet prefabs, and destroying bullets using a trigger collider on the boundary object.
This document summarizes a presentation about the Unity game development platform. It introduces Unity as a game engine that integrates tools for creating 3D and 2D content across platforms. It describes Unity's main components, including the game engine, editor tools, asset store, and support for multiple platforms. It provides screenshots explaining Unity's interface and gives examples of creating a simple space shooter game in Unity, including importing assets, scripting enemy behavior, using prefabs, and adding collisions and a game over scene.
The document discusses GUI event handling in Java. It explains that window-based Java programs are event-driven, meaning they wait for and respond to user-initiated events like button clicks or key presses. When an event occurs, an event object is passed to a listener object that handles the event. Listeners implement interfaces that correspond to different event types, like ActionListener for button clicks. The delegation event model in Java handles event passing from components to listeners.
This document provides an introduction and overview of the Java Swing GUI toolkit. It discusses what Swing is, its main characteristics including being platform independent, customizable, extensible and lightweight. It explains that Swing is written entirely in Java and is part of the Java Foundation Classes. The document also provides examples of simple first programs using Swing including creating a basic window, centering a window, adding buttons and tooltips. It demonstrates creating menus and toolbars and includes examples of submenus and checkbox menu items.
This document provides a tutorial on using the accelerometer sensor in Android applications. It discusses retrieving the accelerometer sensor from the SensorManager, registering a listener, and handling sensor events to detect phone movements like shaking. Code examples are given for an AccelerometerListener interface, AccelerometerManager class to manage sensor access, and an Activity that implements the listener to detect shakes and log accelerometer data.
.NET Gadgeteer is a new toolkit for quickly constructing, programming and shaping new small computing devices (gadgets)
Ideal for teaching computer science, engineering, Design and Technology in schools, colleges and universities more details here http://www.netmf.com/gadgeteer/
Session 12 - Overview of taps, multitouch, and gestures Vu Tran Lam
This document provides an overview of gesture recognition and touch handling in iOS application development. It discusses the responder chain and how touch events are delivered. It also covers creating subclasses of UIResponder to handle touch events, recognizing common gestures like taps, swipes, and pinches, and using gesture recognizers to simplify touch handling. Gesture recognizers can be used to detect gestures and trigger actions in response.
Building a turn-based game prototype using ECS - Unite Copenhagen 2019Unity Technologies
Get a high-level overview of the Entity Component System (ECS) and turn-based game loops, and see a proof of concept built using ECS. These slides will cover some of the pitfalls and also show concepts of ECS in a slightly exotic context.
Speaker:
Florian Uhde - Three Eyed Games
Watch the session on YouTube: https://youtu.be/mL4qrt-15TE
The document discusses Java AWT event handling. It describes how AWT components generate events that are passed to listener objects. It provides examples of common event classes like ActionEvent and MouseEvent, and the interfaces that listener objects must implement like ActionListener and MouseListener. It also gives a simple example of an applet that registers listeners on different components and handles events in the listener methods.
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 outlines the syllabus for an Object Oriented Programming using C++ course. It is divided into 3 sections - Introduction to OOP concepts and C++ basics, Classes and Objects, and Input/Output files. Section I covers OOP characteristics, C++ program statements, functions, arrays and pointers. Section II covers classes, objects, inheritance, polymorphism and static/friend functions. Section III discusses file I/O using streams in C++. The question paper for internal assessment will have 2 parts - short questions from each section in Part A and longer questions covering all sections in Part B.
This document provides instructions for various laboratory animal handling techniques in mice, including blood collection from the tail vein, orbital sinus, and by cardiac puncture. It also describes how to perform intraperitoneal and subcutaneous injections, oral feeding, and sexing of mice. The techniques are explained step-by-step and include lists of the necessary tools and materials to perform each procedure properly to avoid mishandling animals and comply with welfare regulations.
This document discusses file handling in C++. It begins by explaining that files allow data to be stored permanently on secondary storage devices like hard disks, unlike variables in memory. It then covers key topics like:
- The different types of files, such as text files containing readable characters and binary files containing raw data.
- Classes used for file input/output like ifstream, ofstream, and fstream.
- Opening, closing, reading from, and writing to files using functions like open(), close(), get(), put(), seekg(), tellg(), seekp(), and tellp().
- File pointers that track read/write positions and functions to manipulate them.
- Examples of creating
The document discusses file input and output in Java. It covers using the File class to get information about files, using JFileChooser to select files, and different streams for reading and writing files including FileInputStream, FileOutputStream, DataInputStream, DataOutputStream, FileWriter, PrintWriter, FileReader and BufferedReader. It provides examples of using these classes and methods to write bytes, primitive data types and text to files and read them back.
This document discusses different types of arrays in C#, including simple arrays, multidimensional arrays, jagged arrays, and tuples. Simple arrays store elements of the same type and can be initialized with syntax like "datatype[] myArray = new datatype[size]". Multidimensional arrays are indexed by two or more integers. Jagged arrays allow each row to have a different size. Tuples were introduced in .NET 4.0 and act as a way to group multiple data types together.
This chapter discusses various methods of file input and output in Java, including low-level file I/O using FileInputStream and FileOutputStream, high-level file I/O using DataInputStream and DataOutputStream to read and write primitive data types, reading and writing text files using PrintWriter, BufferedReader, and Scanner, and object file I/O using ObjectInputStream and ObjectOutputStream to save and load objects. It also covers using JFileChooser to allow users to select files and applying file filters.
This document discusses different strategies for handling mouse and keyboard events in Java applications, including using separate listener classes, implementing listener interfaces, and defining inner listener classes. It provides examples of drawing shapes in response to mouse clicks and keyboard input. It also summarizes the standard AWT listener types and their corresponding methods.
This document discusses GUI event handling in Java. It introduces the delegation event model where event sources generate event objects that are passed to registered event listeners. It covers common event classes and listener interfaces like ActionListener, MouseListener, and WindowListener. It provides examples of handling mouse and window events using different approaches like inner classes and anonymous inner classes.
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 event handling in Java. It covers using the delegation event model, handling keyboard and mouse events, and using adapter classes. Key points covered include implementing the appropriate interface for the event desired, registering the listener, and providing empty implementations in adapter classes to simplify creating event handlers. Examples are provided to demonstrate handling keyboard and mouse events.
1. The document describes AWT event handling in Java. It discusses the key classes and interfaces involved in event handling like EventListener, EventSource, and EventObject.
2. It provides an example of how to set up basic event handling by implementing listener interfaces, registering listeners with event sources, and handling events in listener methods.
3. The example code shows how to create a simple GUI with buttons and checkboxes, add listeners to those components, and update the display in response to user interactions.
The document discusses Android's windowing system architecture and components. It describes the main components as SurfaceManager, WindowManager, and ActivityManager. SurfaceManager is responsible for compositing surfaces. WindowManager creates and lays out surfaces on behalf of clients and dispatches input events. ActivityManager manages activity lifecycles and stacking. The document also covers handling gestures, animations, custom view architecture, using the hierarchy viewer tool, and event propagation in Android views.
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.
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 discusses the evolution of graphical user interface (GUI) capabilities in the Java programming language. It describes the Abstract Window Toolkit (AWT) introduced in JDK 1.0, which provided basic cross-platform GUI functionality but had limitations. JDK 1.1 improved on AWT with an event delegation model. JDK 1.2 introduced Swing, a richer GUI library that better integrated with native operating system look and feels. Swing components are lightweight compared to heavyweight AWT components. The document also covers GUI component classes, layout managers, menus, labels and event handling in Java GUI programming.
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 various AWT classes and components for creating graphical user interfaces in Java, including buttons, borders, card layouts, checkboxes, text fields, menus, and handling events from mouse clicks and key presses. Code examples are provided to demonstrate drawing shapes and graphics, as well as handling user input events.
This document discusses event-driven programming and graphical user interfaces (GUIs) using Swing/AWT in Java. It provides an overview of key GUI concepts like components, containers, layout managers, and events. It explains how to create basic GUI elements like frames and buttons. It also demonstrates how to write an event listener as a nested class to handle button click events and update the GUI in response.
Java programming presentations By Daroko blog
Do not just read java as a programmer, find projects and start making some Money, at DAROKO BLOG,WE Guide you through what you have learned in the classroom to a real business Environment, find java applications to a real business Environment, find also all IT Solutions and How you can apply them, find the best companies where you can get the IT jobs worldwide, Find java contract, Complete and start making some cash, find clients within your Country, refer and get paid when you complete the work.
Not Just a contact, at daroko Blog (www.professionalbloggertricks.com/),you are also being taught how you can apply all IT related field in real world.
Simply Google, Daroko Blog or visit (www.professionalbloggertricks.com/) to Know More about all these service now.
Do not just learn and go, apply them in real world.
This document discusses events and event handling in openFrameworks. It explains that openFrameworks wraps the Poco events system and allows registering callbacks for built-in events like mouse, keyboard, and touch events. It describes how to register a callback function for an event using ofAddListener, and how to unregister using ofRemoveListener. It also covers creating and dispatching custom events, and using simple messaging between components with ofSendMessage.
The document discusses event handling in Java. It describes how events are generated from user interactions with GUI components and handled via the delegation event model. This model involves events, event sources that generate events, and event listeners that receive and process events. The document lists some important event classes like ActionEvent and MouseEvent, and listener interfaces. It also provides details on how to register listeners with sources and implement event handling in classes.
The document discusses building touchscreen interfaces for mobile devices using Flash Lite. It covers touchscreen technologies, gestural interfaces, coherence with platforms, and considerations for Flash Lite and touch including supporting touch events, building dynamic lists, and performance. Example code is provided to attach listeners for touch events, define the scrollable area, and implement scrolling and selection.
EventBus is an Android optimized publish/subscribe event bus. A typical use case for Android apps is gluing Activities, Fragments, and background threads together.
1. The document discusses various aspects of user input and frame animation in libGDX, including touch input, keyboard input, gestures, the accelerometer, and sprite animation.
2. It explains how to set up input processing using InputProcessor and GestureDetector, and how to read touch, keyboard, and accelerometer values.
3. It also provides examples of creating sprite animations by splitting textures into frames and using the Animation class.
This document provides an overview and tutorial for ASP.NET, including Classic ASP, ASP.NET, ASP.NET Razor, programming languages used in ASP.NET (VB.NET and C#), ASP.NET server technologies (Web Pages, MVC, and Web Forms), development tools, and file extensions. It then demonstrates ASP.NET Web Pages by walking through creating a website from scratch, adding navigation, and connecting a database. The tutorial covers creating folders, files, stylesheets, layout pages, and database tables. It demonstrates displaying and adding data to the database.
The document provides a tutorial on PHP programming. It discusses what PHP is, how to install PHP, basic PHP syntax like variables and data types, and how to use PHP with HTML. It also covers PHP programming concepts like strings, operators, conditional statements, arrays, and more. The tutorial aims to teach the fundamentals of PHP to help readers get started with learning PHP.
The document discusses the benefits of exercise for mental health. Regular physical activity can help reduce anxiety and depression and improve mood and cognitive function. Exercise causes chemical changes in the brain that may help protect against mental illness and improve symptoms.
The document discusses Java exception handling. It begins with defining what exceptions are and what happens when exceptions occur. It then covers benefits of Java's exception handling framework such as separating error handling code from regular code, propagating errors up the call stack, and grouping exception types into hierarchies. The document also discusses how to catch exceptions using try-catch blocks and the finally keyword. It covers rules for throwing exceptions and shows Java's built-in exception class hierarchy.
The document discusses the concept of inheritance in object-oriented programming. It defines inheritance as a child class automatically inheriting variables and methods from its parent class. The key benefits of inheritance are reusability of code and properties. The document explains how to create a subclass using the extends keyword, the constructor calling chain, and use of the super keyword. It also covers overriding and hiding methods, hiding fields, type casting, and final classes and methods.
The document discusses Remote Method Invocation (RMI) in Java, including its architectural components like remote interfaces, stubs, and skeletons; how objects are serialized and classes dynamically loaded during remote calls; and how to configure the RMI codebase property to specify locations for downloading classes.
1. Inheritance in Java allows classes to extend other classes and interfaces to implement other interfaces. This allows code reuse and establishes type constraints.
2. Abstract classes can contain both abstract and non-abstract methods while interfaces contain only abstract methods. Interfaces establish contracts that implementing classes must follow.
3. When constructing objects with inheritance, superclass constructors are called before subclass constructors. Abstract classes and interfaces allow incomplete implementations to be extended.
This document provides an overview of using Hibernate, an open source Java object-relational mapping tool. It discusses typical problems with JDBC code, how Hibernate addresses these issues, and provides sample code for mapping Java objects to database tables and performing queries and transactions with Hibernate. The document also outlines steps for a basic Hibernate tutorial, including database design, mapping classes, configuration, and data access objects.
This document discusses packages, classpaths, and how to organize Java source files and classes. It explains that packages group related classes and interfaces, provide access protection and namespace management. It describes how to declare a package, place classes in packages, import packages and classes from other packages. It also covers setting the classpath so the Java runtime can locate class files, and recommended directory structures that match the package hierarchy for source and class files.
Arrays allow storing multiple values of the same type in contiguous memory locations. An array is declared with the data type followed by square brackets and the array name. The array is instantiated using the new keyword and square brackets containing the size. Array elements are accessed using an index from 0 to length-1. The length field returns the array size. Multidimensional arrays are arrays of arrays, declared with multiple bracket pairs after the name.
This document provides an overview of the Abstract Windowing Toolkit (AWT) and Swing GUI frameworks in Java. It discusses the similarities and differences between AWT and Swing, the fundamental AWT components like frames and panels, graphics drawing, additional AWT components, common layout managers, and how to set up top-level containers and examples using Swing components like JFrames and JOptionPanes. The key topics covered include the fundamentals of building graphical user interfaces in Java.
This document provides a tutorial on summarizing the Spring Framework. It introduces the main packages in Spring Framework including the JDBC package for data access. The JDBC package has two main subpackages - com.interface21.jdbc.core which implements low-level persistence and com.interface21.jdbc.object which presents an object-oriented view. It provides code samples demonstrating how to perform queries, updates and retrieve results using these packages.
The document provides an overview of the Struts 1.1 framework. It introduces Struts and describes its core components - the controller, model, and view. It discusses how Struts implements the MVC pattern and follows the JSP Model 2 architecture. It highlights some of the key features of Struts 1.1, including internationalization support, tag libraries, and configuration. It also provides an example of building a sample application called Beer4All to demonstrate how to use Struts.
This document discusses Java threads and related concepts like thread states, priorities, synchronization, and inter-thread communication. It covers the two main ways to create threads in Java - by extending the Thread class or implementing the Runnable interface. Synchronization techniques like using synchronized methods and blocks are presented to prevent race conditions when multiple threads access shared resources. Finally, inter-thread communication methods like wait() and notify() from the Object class are introduced.
JavaBeans are reusable software components that can be visually composed using builder tools. They have properties that can be edited visually, support events to communicate between components, and allow introspection to discover their features. JavaBeans use serialization and XML for persistence so their state can be saved and restored. They provide a portable, platform-independent way to create reusable application components.
The document introduces the Model-View-Controller (MVC) design pattern and the Struts framework. It describes the key components of MVC - the Model, View, and Controller. It then explains how Struts implements each component and allows developers to build dynamic web applications using MVC. Struts handles common tasks like separating business logic from presentation, internationalization, and connecting user input to application processing. Developers can focus on application logic rather than framework details.
This document provides an overview of key concepts related to Java networking. It discusses IP addresses, protocols, ports, and the client-server paradigm as basic networking concepts. It then describes Java's networking package, including the ServerSocket and Socket classes for creating server and client sockets, and the MulticastSocket and DatagramPacket classes for multicast communication. Example code is provided to illustrate using the ServerSocket and Socket classes to create a simple echo server and client.
This document discusses Java I/O streams. It defines streams as representing input sources or output destinations that can represent files, devices, programs, sockets or memory arrays. Streams support different data types like bytes, primitive types, characters or objects. The document outlines the stream class hierarchy with abstract classes like InputStream, OutputStream, Reader and Writer. It describes node streams that interact with specific locations and filter streams that process or alter data. Examples of byte streams like FileInputStream and character streams like FileReader are provided.
Essentials of Automations: The Art of Triggers and Actions in FMESafe Software
In this second installment of our Essentials of Automations webinar series, we’ll explore the landscape of triggers and actions, guiding you through the nuances of authoring and adapting workspaces for seamless automations. Gain an understanding of the full spectrum of triggers and actions available in FME, empowering you to enhance your workspaces for efficient automation.
We’ll kick things off by showcasing the most commonly used event-based triggers, introducing you to various automation workflows like manual triggers, schedules, directory watchers, and more. Plus, see how these elements play out in real scenarios.
Whether you’re tweaking your current setup or building from the ground up, this session will arm you with the tools and insights needed to transform your FME usage into a powerhouse of productivity. Join us to discover effective strategies that simplify complex processes, enhancing your productivity and transforming your data management practices with FME. Let’s turn complexity into clarity and make your workspaces work wonders!
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024Neo4j
Neha Bajwa, Vice President of Product Marketing, Neo4j
Join us as we explore breakthrough innovations enabled by interconnected data and AI. Discover firsthand how organizations use relationships in data to uncover contextual insights and solve our most pressing challenges – from optimizing supply chains, detecting fraud, and improving customer experiences to accelerating drug discoveries.
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Speck&Tech
ABSTRACT: A prima vista, un mattoncino Lego e la backdoor XZ potrebbero avere in comune il fatto di essere entrambi blocchi di costruzione, o dipendenze di progetti creativi e software. La realtà è che un mattoncino Lego e il caso della backdoor XZ hanno molto di più di tutto ciò in comune.
Partecipate alla presentazione per immergervi in una storia di interoperabilità, standard e formati aperti, per poi discutere del ruolo importante che i contributori hanno in una comunità open source sostenibile.
BIO: Sostenitrice del software libero e dei formati standard e aperti. È stata un membro attivo dei progetti Fedora e openSUSE e ha co-fondato l'Associazione LibreItalia dove è stata coinvolta in diversi eventi, migrazioni e formazione relativi a LibreOffice. In precedenza ha lavorato a migrazioni e corsi di formazione su LibreOffice per diverse amministrazioni pubbliche e privati. Da gennaio 2020 lavora in SUSE come Software Release Engineer per Uyuni e SUSE Manager e quando non segue la sua passione per i computer e per Geeko coltiva la sua curiosità per l'astronomia (da cui deriva il suo nickname deneb_alpha).
Pushing the limits of ePRTC: 100ns holdover for 100 daysAdtran
At WSTS 2024, Alon Stern explored the topic of parametric holdover and explained how recent research findings can be implemented in real-world PNT networks to achieve 100 nanoseconds of accuracy for up to 100 days.
Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...Zilliz
Join us to introduce Milvus Lite, a vector database that can run on notebooks and laptops, share the same API with Milvus, and integrate with every popular GenAI framework. This webinar is perfect for developers seeking easy-to-use, well-integrated vector databases for their GenAI apps.
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc
How does your privacy program stack up against your peers? What challenges are privacy teams tackling and prioritizing in 2024?
In the fifth annual Global Privacy Benchmarks Survey, we asked over 1,800 global privacy professionals and business executives to share their perspectives on the current state of privacy inside and outside of their organizations. This year’s report focused on emerging areas of importance for privacy and compliance professionals, including considerations and implications of Artificial Intelligence (AI) technologies, building brand trust, and different approaches for achieving higher privacy competence scores.
See how organizational priorities and strategic approaches to data security and privacy are evolving around the globe.
This webinar will review:
- The top 10 privacy insights from the fifth annual Global Privacy Benchmarks Survey
- The top challenges for privacy leaders, practitioners, and organizations in 2024
- Key themes to consider in developing and maintaining your privacy program
Unlocking Productivity: Leveraging the Potential of Copilot in Microsoft 365, a presentation by Christoforos Vlachos, Senior Solutions Manager – Modern Workplace, Uni Systems
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...James Anderson
Effective Application Security in Software Delivery lifecycle using Deployment Firewall and DBOM
The modern software delivery process (or the CI/CD process) includes many tools, distributed teams, open-source code, and cloud platforms. Constant focus on speed to release software to market, along with the traditional slow and manual security checks has caused gaps in continuous security as an important piece in the software supply chain. Today organizations feel more susceptible to external and internal cyber threats due to the vast attack surface in their applications supply chain and the lack of end-to-end governance and risk management.
The software team must secure its software delivery process to avoid vulnerability and security breaches. This needs to be achieved with existing tool chains and without extensive rework of the delivery processes. This talk will present strategies and techniques for providing visibility into the true risk of the existing vulnerabilities, preventing the introduction of security issues in the software, resolving vulnerabilities in production environments quickly, and capturing the deployment bill of materials (DBOM).
Speakers:
Bob Boule
Robert Boule is a technology enthusiast with PASSION for technology and making things work along with a knack for helping others understand how things work. He comes with around 20 years of solution engineering experience in application security, software continuous delivery, and SaaS platforms. He is known for his dynamic presentations in CI/CD and application security integrated in software delivery lifecycle.
Gopinath Rebala
Gopinath Rebala is the CTO of OpsMx, where he has overall responsibility for the machine learning and data processing architectures for Secure Software Delivery. Gopi also has a strong connection with our customers, leading design and architecture for strategic implementations. Gopi is a frequent speaker and well-known leader in continuous delivery and integrating security into software delivery.
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfMalak Abu Hammad
Discover how MongoDB Atlas and vector search technology can revolutionize your application's search capabilities. This comprehensive presentation covers:
* What is Vector Search?
* Importance and benefits of vector search
* Practical use cases across various industries
* Step-by-step implementation guide
* Live demos with code snippets
* Enhancing LLM capabilities with vector search
* Best practices and optimization strategies
Perfect for developers, AI enthusiasts, and tech leaders. Learn how to leverage MongoDB Atlas to deliver highly relevant, context-aware search results, transforming your data retrieval process. Stay ahead in tech innovation and maximize the potential of your applications.
#MongoDB #VectorSearch #AI #SemanticSearch #TechInnovation #DataScience #LLM #MachineLearning #SearchTechnology
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!SOFTTECHHUB
As the digital landscape continually evolves, operating systems play a critical role in shaping user experiences and productivity. The launch of Nitrux Linux 3.5.0 marks a significant milestone, offering a robust alternative to traditional systems such as Windows 11. This article delves into the essence of Nitrux Linux 3.5.0, exploring its unique features, advantages, and how it stands as a compelling choice for both casual users and tech enthusiasts.
A tale of scale & speed: How the US Navy is enabling software delivery from l...sonjaschweigert1
Rapid and secure feature delivery is a goal across every application team and every branch of the DoD. The Navy’s DevSecOps platform, Party Barge, has achieved:
- Reduction in onboarding time from 5 weeks to 1 day
- Improved developer experience and productivity through actionable findings and reduction of false positives
- Maintenance of superior security standards and inherent policy enforcement with Authorization to Operate (ATO)
Development teams can ship efficiently and ensure applications are cyber ready for Navy Authorizing Officials (AOs). In this webinar, Sigma Defense and Anchore will give attendees a look behind the scenes and demo secure pipeline automation and security artifacts that speed up application ATO and time to production.
We will cover:
- How to remove silos in DevSecOps
- How to build efficient development pipeline roles and component templates
- How to deliver security artifacts that matter for ATO’s (SBOMs, vulnerability reports, and policy evidence)
- How to streamline operations with automated policy checks on container images
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionAggregage
Join Maher Hanafi, VP of Engineering at Betterworks, in this new session where he'll share a practical framework to transform Gen AI prototypes into impactful products! He'll delve into the complexities of data collection and management, model selection and optimization, and ensuring security, scalability, and responsible use.
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfPaige Cruz
Monitoring and observability aren’t traditionally found in software curriculums and many of us cobble this knowledge together from whatever vendor or ecosystem we were first introduced to and whatever is a part of your current company’s observability stack.
While the dev and ops silo continues to crumble….many organizations still relegate monitoring & observability as the purview of ops, infra and SRE teams. This is a mistake - achieving a highly observable system requires collaboration up and down the stack.
I, a former op, would like to extend an invitation to all application developers to join the observability party will share these foundational concepts to build on:
Communications Mining Series - Zero to Hero - Session 1DianaGray10
This session provides introduction to UiPath Communication Mining, importance and platform overview. You will acquire a good understand of the phases in Communication Mining as we go over the platform with you. Topics covered:
• Communication Mining Overview
• Why is it important?
• How can it help today’s business and the benefits
• Phases in Communication Mining
• Demo on Platform overview
• Q/A
2. Agenda
• General event-handling strategy
• Handling events with separate listeners
• Handling events by implementing interfaces
• Handling events with named inner classes
• Handling events with anonymous inner
classes
• The standard AWT listener types
• Subtleties with mouse events
• Examples
2 Handling Mouse and Keyboard Events www.corewebprogramming.com
3. General Strategy
• Determine what type of listener is of interest
– 11 standard AWT listener types, described on later slide.
• ActionListener, AdjustmentListener,
ComponentListener, ContainerListener,
FocusListener, ItemListener, KeyListener,
MouseListener, MouseMotionListener, TextListener,
WindowListener
• Define a class of that type
– Implement interface (KeyListener, MouseListener, etc.)
– Extend class (KeyAdapter, MouseAdapter, etc.)
• Register an object of your listener class
with the window
– w.addXxxListener(new MyListenerClass());
3
• E.g., addKeyListener, addMouseListener
Handling Mouse and Keyboard Events www.corewebprogramming.com
4. Handling Events with a
Separate Listener: Simple Case
• Listener does not need to call any methods
of the window to which it is attached
import java.applet.Applet;
import java.awt.*;
public class ClickReporter extends Applet {
public void init() {
setBackground(Color.yellow);
addMouseListener(new ClickListener());
}
}
4 Handling Mouse and Keyboard Events www.corewebprogramming.com
5. Separate Listener: Simple Case
(Continued)
import java.awt.event.*;
public class ClickListener extends MouseAdapter {
public void mousePressed(MouseEvent event) {
System.out.println("Mouse pressed at (" +
event.getX() + "," +
event.getY() + ").");
}
}
5 Handling Mouse and Keyboard Events www.corewebprogramming.com
6. Generalizing Simple Case
• What if ClickListener wants to draw a circle
wherever mouse is clicked?
• Why can’t it just call getGraphics to get a
Graphics object with which to draw?
• General solution:
– Call event.getSource to obtain a reference to window or
GUI component from which event originated
– Cast result to type of interest
– Call methods on that reference
6 Handling Mouse and Keyboard Events www.corewebprogramming.com
7. Handling Events with Separate
Listener: General Case
import java.applet.Applet;
import java.awt.*;
public class CircleDrawer1 extends Applet {
public void init() {
setForeground(Color.blue);
addMouseListener(new CircleListener());
}
}
7 Handling Mouse and Keyboard Events www.corewebprogramming.com
8. Separate Listener: General
Case (Continued)
import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
public class CircleListener extends MouseAdapter {
private int radius = 25;
public void mousePressed(MouseEvent event) {
Applet app = (Applet)event.getSource();
Graphics g = app.getGraphics();
g.fillOval(event.getX()-radius,
event.getY()-radius,
2*radius,
2*radius);
}
}
8 Handling Mouse and Keyboard Events www.corewebprogramming.com
9. Separate Listener: General
Case (Results)
9 Handling Mouse and Keyboard Events www.corewebprogramming.com
10. Case 2: Implementing a
Listener Interface
import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
public class CircleDrawer2 extends Applet
implements MouseListener {
private int radius = 25;
public void init() {
setForeground(Color.blue);
addMouseListener(this);
}
10 Handling Mouse and Keyboard Events www.corewebprogramming.com
11. Implementing a Listener
Interface (Continued)
public void mouseEntered(MouseEvent event) {}
public void mouseExited(MouseEvent event) {}
public void mouseReleased(MouseEvent event) {}
public void mouseClicked(MouseEvent event) {}
public void mousePressed(MouseEvent event) {
Graphics g = getGraphics();
g.fillOval(event.getX()-radius,
event.getY()-radius,
2*radius,
2*radius);
}
}
11 Handling Mouse and Keyboard Events www.corewebprogramming.com
12. Case 3: Named Inner Classes
import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
public class CircleDrawer3 extends Applet {
public void init() {
setForeground(Color.blue);
addMouseListener(new CircleListener());
}
12 Handling Mouse and Keyboard Events www.corewebprogramming.com
13. Named Inner Classes
(Continued)
• Note: still part of class from previous slide
private class CircleListener
extends MouseAdapter {
private int radius = 25;
public void mousePressed(MouseEvent event) {
Graphics g = getGraphics();
g.fillOval(event.getX()-radius,
event.getY()-radius,
2*radius,
2*radius);
}
}
}
13 Handling Mouse and Keyboard Events www.corewebprogramming.com
14. Case 4: Anonymous Inner
Classes
public class CircleDrawer4 extends Applet {
public void init() {
setForeground(Color.blue);
addMouseListener
(new MouseAdapter() {
private int radius = 25;
public void mousePressed(MouseEvent event) {
Graphics g = getGraphics();
g.fillOval(event.getX()-radius,
event.getY()-radius,
2*radius,
2*radius);
}
});
}
}
14 Handling Mouse and Keyboard Events www.corewebprogramming.com
15. Event Handling Strategies:
Pros and Cons
• Separate Listener
– Advantages
• Can extend adapter and thus ignore unused methods
• Separate class easier to manage
– Disadvantage
• Need extra step to call methods in main window
• Main window that implements interface
– Advantage
• No extra steps needed to call methods in main
window
– Disadvantage
• Must implement methods you might not care about
15 Handling Mouse and Keyboard Events www.corewebprogramming.com
16. Event Handling Strategies:
Pros and Cons (Continued)
• Named inner class
– Advantages
• Can extend adapter and thus ignore unused methods
• No extra steps needed to call methods in main
window
– Disadvantage
• A bit harder to understand
• Anonymous inner class
– Advantages
• Same as named inner classes
• Even shorter
– Disadvantage
• Much harder to understand
16 Handling Mouse and Keyboard Events www.corewebprogramming.com
20. Standard AWT Event Listeners
(Details Continued)
• ItemListener
– Handles selections in lists, checkboxes, etc.
• itemStateChanged(ItemEvent event)
• KeyListener
– Detects keyboard events
• keyPressed(KeyEvent event) -- any key pressed
down
• keyReleased(KeyEvent event) -- any key released
• keyTyped(KeyEvent event) -- key for printable char
released
20 Handling Mouse and Keyboard Events www.corewebprogramming.com
21. Standard AWT Event Listeners
(Details Continued)
• MouseListener
– Applies to basic mouse events
• mouseEntered(MouseEvent event)
• mouseExited(MouseEvent event)
• mousePressed(MouseEvent event)
• mouseReleased(MouseEvent event)
• mouseClicked(MouseEvent event) -- Release without
drag
– Applies on release if no movement since press
• MouseMotionListener
– Handles mouse movement
• mouseMoved(MouseEvent event)
• mouseDragged(MouseEvent event)
21 Handling Mouse and Keyboard Events www.corewebprogramming.com
22. Standard AWT Event Listeners
(Details Continued)
• TextListener
– Applies to textfields and text areas
• textValueChanged(TextEvent event)
• WindowListener
– Handles high-level window events
• windowOpened, windowClosing, windowClosed,
windowIconified, windowDeiconified,
windowActivated, windowDeactivated
– windowClosing particularly useful
22 Handling Mouse and Keyboard Events www.corewebprogramming.com
23. Mouse Events: Details
• MouseListener and MouseMotionListener
share event types
• Location of clicks
– event.getX() and event.getY()
• Double clicks
– Determined by OS, not by programmer
– Call event.getClickCount()
• Distinguishing mouse buttons
– Call event.getModifiers() and compare to
MouseEvent.Button2_MASK for a middle click and
MouseEvent.Button3_MASK for right click.
– Can also trap Shift-click, Alt-click, etc.
23 Handling Mouse and Keyboard Events www.corewebprogramming.com
24. Simple Example: Spelling-
Correcting Textfield
• KeyListener corrects spelling during typing
• ActionListener completes word on ENTER
• FocusListener gives subliminal hints
24 Handling Mouse and Keyboard Events www.corewebprogramming.com
25. Example: Simple Whiteboard
import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
public class SimpleWhiteboard extends Applet {
protected int lastX=0, lastY=0;
public void init() {
setBackground(Color.white);
setForeground(Color.blue);
addMouseListener(new PositionRecorder());
addMouseMotionListener(new LineDrawer());
}
protected void record(int x, int y) {
lastX = x; lastY = y;
}
25 Handling Mouse and Keyboard Events www.corewebprogramming.com
26. Simple Whiteboard (Continued)
private class PositionRecorder extends MouseAdapter {
public void mouseEntered(MouseEvent event) {
requestFocus(); // Plan ahead for typing
record(event.getX(), event.getY());
}
public void mousePressed(MouseEvent event) {
record(event.getX(), event.getY());
}
}
...
26 Handling Mouse and Keyboard Events www.corewebprogramming.com
27. Simple Whiteboard (Continued)
...
private class LineDrawer extends MouseMotionAdapter {
public void mouseDragged(MouseEvent event) {
int x = event.getX();
int y = event.getY();
Graphics g = getGraphics();
g.drawLine(lastX, lastY, x, y);
record(x, y);
}
}
}
27 Handling Mouse and Keyboard Events www.corewebprogramming.com
29. Whiteboard: Adding Keyboard
Events
import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
public class Whiteboard extends SimpleWhiteboard {
protected FontMetrics fm;
public void init() {
super.init();
Font font = new Font("Serif", Font.BOLD, 20);
setFont(font);
fm = getFontMetrics(font);
addKeyListener(new CharDrawer());
}
29 Handling Mouse and Keyboard Events www.corewebprogramming.com
30. Whiteboard (Continued)
...
private class CharDrawer extends KeyAdapter {
// When user types a printable character,
// draw it and shift position rightwards.
public void keyTyped(KeyEvent event) {
String s = String.valueOf(event.getKeyChar());
getGraphics().drawString(s, lastX, lastY);
record(lastX + fm.stringWidth(s), lastY);
}
}
}
30 Handling Mouse and Keyboard Events www.corewebprogramming.com
32. Summary
• General strategy
– Determine what type of listener is of interest
• Check table of standard types
– Define a class of that type
• Extend adapter separately, implement interface,
extend adapter in named inner class, extend adapter
in anonymous inner class
– Register an object of your listener class with the window
• Call addXxxListener
• Understanding listeners
– Methods give specific behavior.
• Arguments to methods are of type XxxEvent
– Methods in MouseEvent of particular interest
32 Handling Mouse and Keyboard Events www.corewebprogramming.com
34. Preview
• Whiteboard had freehand drawing only
– Need GUI controls to allow selection of other drawing
methods
• Whiteboard had only “temporary” drawing
– Covering and reexposing window clears drawing
– After cover multithreading, we’ll see solutions to this
problem
• Most general is double buffering
• Whiteboard was “unshared”
– Need network programming capabilities so that two
different whiteboards can communicate with each other
34 Handling Mouse and Keyboard Events www.corewebprogramming.com