Arc: Events Dr Andy Evans. Event communication Arc is, plainly, set up for Event Based Programming. You can register listeners with most GUI components.

Slides:



Advertisements
Similar presentations
Event Handling Feb 14, Event Model Revisited zRecall that a component can fire an event. zEach type of event is defined as a distinct class. zAn.
Advertisements

Programming with Java © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 1 Chapter 12 More OOP, Interfaces, and Inner Classes.
Event Handling. In this class we will cover: Basics of event handling The AWT event hierarchy Semantic and low-level events in the AWT.
Gui Interfaces a la Swing Up to speed with Swing by Steven Gutz is a good source It don’t mean a thing if it ain’t got that swing Duke Ellington.
Events ● Anything that happens in a GUI is an event. For example: – User clicks a button, presses return when typing text, or chooses a menu item ( ActionEvent.
For IST410 Students only Events-1 Event Handling.
Event Handling n Events: an event is an object that describes a state change in a source. n Event Sources: A source is an object that generates an event.
Event-Driven Programming
Intermediate Java1 An example that uses inner classes Week Four Continued.
1 lecture 12Lecture 13 Event Handling (cont.) Overview  Handling Window Events.  Event Adapters Revisited.  Introduction to Components and Containers.
10.1 AWT The AWT classes Users today expect a Graphical User Interface (GUI) Improves application usability Difficult to implement cross-platform.
GUI Basics and Event- Driven Programming Feb 7, 2000.
PROG Mobile Java Application Development PROG Mobile Java Application Development Event Handling Creating Menus.
Arc: Programming Options Dr Andy Evans. Programming ArcGIS ArcGIS: Most popular commercial GIS. Out of the box functionality good, but occasionally: You.
Programming for Geographical Information Analysis: Advanced Skills Lecture 4: Arc Data Editing Addin Programming Dr Andy Evans.
Activity 3: Skills map.
Arc: AddIns Dr Andy Evans. Java Direct access to ArcObjects Framework inside and outside Arc. Ability to add components to the GUI. Ability to communicate.
1 CSC111H Graphical User Interfaces (GUIs) Introduction GUIs in Java Understanding Events A Simple Application The Containment Hierarchy Layout Managers.
More Event Handling Adapters Anonymous Listeners Pop menus Validating User Input.
Arc: Accessing the Framework Dr Andy Evans. Code The code that goes in the addIn is then code to work with the ArcObjects framework. Ask App for Document.
1 CSC111H Graphical User Interfaces (GUIs) Introduction GUIs in Java Understanding Events A Simple Application The Containment Hierarchy Layout Managers.
Object-Oriented Programming (Java), Unit 18 Kirk Scott 1.
Chapter 12 Handling Exceptions and Events. Chapter Objectives Learn what an exception is Become aware of the hierarchy of exception classes Learn about.
Event Driven Programming. Event-driven Programming In the early days of computing communication with the outside world was accomplished using a technique.
Pravin Yannawar, DOCS, NMU Jalgaon. Basic Java : Event handling in AWT and Swing 2 Objectives of This Session Explain the Event handling mechanism & demonstrate.
Object-Oriented Program Development Using Java: A Class-Centered Approach, Enhanced Edition.
 GUI – Graphic User Interface  Up to now in the programs we have written all output has been sent to the standard output device i.e.: the DOS console.
Creating a GUI with JFC/Swing. What are the JFC and Swing? JFC –Java Foundation Classes –a group of features to help people build graphical user interfaces.
CS-1020 Dr. Mark L. Hornick 1 Event-Driven Programming.
Anonymous Classes An anonymous class is a local class that does not have a name. An anonymous class allows an object to be created using an expression.
Week 6: Basic GUI Programming Concepts in Java Example: JFrameDemo.java container : a screen window/applet window/panel that groups and arranges components.
Object Oriented Programming.  Interface  Event Handling.
Ch13 Creating windows and applets. Short overview AWT (Abstract Windowing Toolkit) Early Java development used graphic classesEarly Java development used.
©2000, John Wiley & Sons, Inc. Horstmann/Java Essentials, 2/e Chapter 10: Event Handling 1 Event Handling.
Graphics in Java Dr. Andrew Wallace PhD BEng(hons) EurIng
Video Games list lab 6  At the end of this lab you will be expected to know:  What Views, View Groups, Layouts, and Widgets are and how they relate to.
Swing. Introduction to Swing What is Swing? “ Swing is a diverse collection of lightweight components that can be used to build sophisticated user interfaces.”
CIS Intro to JAVA Lecture Notes Set 8 9-June-05.
©2000, John Wiley & Sons, Inc. Horstmann/Java Essentials, 2/e Chapter 10: Event Handling 1 Chapter 10 Event Handling.
Event Handling. User actions are called “events” – Low-level window events Window changes – Low-level component events Mouse events, Keyboard events,
Java the UML Way versjon Only to be used in connection with the book "Java the UML Way", by Else Lervik and.
Event-Driven Programming CSCI 201L Jeffrey Miller, Ph.D. HTTP :// WWW - SCF. USC. EDU /~ CSCI 201 USC CSCI 201L.
Designing user interfaces using: Simple views 1. Views Basic views – TextView – EditText – Button – ImageButton – CheckBox – ToggleButton – RadioButton.
Creating a GUI Class An example of class design using inheritance and interfaces.
1 Event Driven Programs Rick Mercer. 2 So what happens next?  You can layout a real pretty GUI  You can click on buttons, enter text into a text field,
Event-Driven Programming F Procedural programming is executed in procedural order. F In event-driven programming, code is executed upon activation of events.
Duke CPS Modules in Java l Classes that are related should be grouped together, may even share access to otherwise private methods/instance variables.
Programming for Geographical Information Analysis: Advanced Skills Lecture 3: Arc Data Framework Dr Andy Evans.
Slides prepared by Rose Williams, Binghamton University Chapter 19 Swing II.
Chapter 10 - Writing Graphical User Interfaces1 Chapter 10 Writing Graphical User Interfaces.
User Interface Layout Interaction. EventsEvent Handlers/Listeners Interacting with a user.
Object Oriented Programming in Java Habib Rostami Lecture 10.
UQC117S2 Graphics Programming Lecture 2 Event Handling Program as a sequence of instructions Event -driven program Need to detect the event and carry out.
Sep 181 Example Program DemoTranslateEnglishGUI.java.
CSC 205 Programming II Lecture 7 AWT – Event Handling & Layout.
1 DemoBasic_v3, DemoBasic_v4 JButton JLabel. 2 Registering an ActionListener Register by invoking the following from within constructor DemoBasicFrame.
Event Driven (Asynchronous) Programming. Event handling in Unity Subclass a class that contains event handling methods, and then override those methods.
Windows 7 Ultimate
Events and Event Handling
GUI III IS
Java GUI.
PC02 Term 1 Project Basic Messenger. PC02 Term 1 Project Basic Messenger.
Introduction to Computing Using Java
Web Design & Development Lecture 13
Graphical User Interfaces in Java Event-driven programming
Arc: Getting Layers Dr Andy Evans.
1 Graphical User Interfaces
Lecture 11 Objectives Learn what an exception is.
Chapter 15 Event-Driven Programming and Animations Part 1
Java Programming: From Problem Analysis to Program Design, 4e
Presentation transcript:

Arc: Events Dr Andy Evans

Event communication Arc is, plainly, set up for Event Based Programming. You can register listeners with most GUI components and many non-GUI components (for example, for data changes).

Useful MxDocument: addIDocumentEventsDispListener Map : addIActiveViewEventsListener Map : addIMapEventsListener FeatureLayer : addIFeatureLayerSelectionEventsListener TIN/Raster/Feature/NetworkLayer : addILayerEventsListener

Adapters We saw that java.awt supplies Adapter classes. These are classes that match an interface, but with nothing in the methods. You can extend the class, and then override the methods you want to, without having to do all of them. However, we saw them in anonymous inner classes.

Shutting a Window myFrame.addWindowListener( new WindowAdapter(){ public void windowClosing(WindowEvent e){ System.exit(0); } ); Arc has a number of Adapters you can use like this for key jobs. Check what classes implement the Listeners in the docs.

New document ((MxDocument)mxDoc).addIDocumentEventsListener( new public void newDocument (IDocumentEventsNewDocumentEvent e){ // Do something when new document. } ); NB: This needs some additional try-catch blocks.

Closing document ((MxDocument)mxDoc).addIDocumentEventsListener( new public boolean beforeCloseDocument (IDocumentEventsBeforeCloseDocumentEvent e){ // Do something when closing document. } );

Dirty, dirty, document If you close a document but have made programmatic changes to it, this can be lost unless the user saves the map. To ask the user if they want to, set the document as “dirty”, e.g. at the end of the beforeCloseDocument method. IDocumentDirty doc = (IDocumentDirty)app.getDocument(); doc.setDirty(); They will then be asked before final closing.

DIY Of course, you can make your own listeners. Just add a new class to your project/package.