Programming Logic and Design Fourth Edition, Comprehensive Chapter 14 Event-Driven Programming with Graphical User Interfaces.

Slides:



Advertisements
Similar presentations
Chapter 8 Improving the User Interface
Advertisements

C++ Programming: Program Design Including Data Structures, Fourth Edition Chapter 15: Exception Handling.
Chapter 16: Exception Handling C++ Programming: From Problem Analysis to Program Design, Fifth Edition.
C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 16: Exception Handling.
Microsoft VB 2005: Reloaded, Advanced Chapter 5 Input Validation, Error Handling, and Exception Handling.
Java Programming, 3e Concepts and Techniques Chapter 4 Decision Making and Repetition with Reusable Objects.
Guide to Oracle10G1 Introduction To Forms Builder Chapter 5.
Using Visual Basic 6.0 to Create Web-Based Database Applications
Chapter 11 Exception Handling and Event Handling.
A Guide to Oracle9i1 Introduction To Forms Builder Chapter 5.
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
Chapter 2: Developing a Program Extended and Concise Prelude to Programming Concepts and Design Copyright © 2003 Scott/Jones, Inc.. All rights reserved.
Chapter 13: Object-Oriented Programming
Chapter 1 Program Design
Chapter 14: Event-Driven Programming with Graphical User Interfaces
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
Chapter 7 Improving the User Interface
1 An Introduction to Visual Basic Objectives Explain the history of programming languages Define the terminology used in object-oriented programming.
Microsoft Visual Basic 2010: Reloaded Fourth Edition Chapter One An Introduction to Visual Basic 2010.
Chapter 9 Introduction to ActionScript 3.0. Chapter 9 Lessons 1.Understand ActionScript Work with instances of movie clip symbols 3.Use code snippets.
Visual Basic Chapter 1 Mr. Wangler.
Hands-on Introduction to Visual Basic.NET Programming Right from the Start with Visual Basic.NET 1/e 6.
Introduction to Visual Basic (VB)
1 Chapter Eight Exception Handling. 2 Objectives Learn about exceptions and the Exception class How to purposely generate a SystemException Learn about.
Chapter 12: Exception Handling
Microsoft Visual Basic 2005: Reloaded Second Edition
Extended Prelude to Programming Concepts & Design, 3/e by Stewart Venit and Elizabeth Drake Chapter 2: Developing a Program.
An Object-Oriented Approach to Programming Logic and Design
Microsoft Visual Basic 2008 CHAPTER 8 Using Procedures and Exception Handling.
Chapter 1 P. 1 Writing Windows applications with Visual Basic Figure 1.1 The first program works as follows: (These operations can be performed in any.
Using Visual Basic 6.0 to Create Web-Based Database Applications
Microsoft Visual Basic 2010: Reloaded Fourth Edition Chapter Six Repeating Program Instructions.
Chapter 8: Writing Graphical User Interfaces
© 2006 Lawrenceville Press Slide 1 Chapter 3 Visual Basic Interface.
Chapter 9 Event-Driven Programming with Graphical User Interfaces
Microsoft Visual Basic 2010: Reloaded Fourth Edition Chapter Twelve Access Databases and LINQ.
Chapter 5 Menus, Common Dialog Boxes, and Methods Programming in C#.NET © 2003 by The McGraw-Hill Companies, Inc. All rights reserved.
Chapter 8: Writing Graphical User Interfaces Visual Basic.NET Programming: From Problem Analysis to Program Design.
Tutorial 111 The Visual Studio.NET Environment The major differences between Visual Basic 6.0 and Visual Basic.NET are the latter’s support for true object-oriented.
Chapter One An Introduction to Visual Basic 2010 Programming with Microsoft Visual Basic th Edition.
CHAPTER TWO INTRODUCTION TO VISUAL BASIC © Prepared By: Razif Razali 1.
Chapter 14: Exception Handling. Objectives In this chapter, you will: – Learn what an exception is – Learn how to handle exceptions within a program –
Chapter Two Creating a First Project in Visual Basic.
Creating Graphical User Interfaces (GUI’s) with MATLAB By Jeffrey A. Webb OSU Gateway Coalition Member.
Chapter 12 Handling Exceptions and Events. Chapter Objectives Learn what an exception is Become aware of the hierarchy of exception classes Learn about.
Practical Programming COMP153-08S Week 5 Lecture 1: Screen Design Subroutines and Functions.
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design Second Edition by Tony Gaddis.
GUI development with Matlab: GUI Front Panel Components GUI development with Matlab: Other GUI Components 1 Other GUI components In this section, we will.
Copyright © 2015 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 13 GUI Programming.
Java Programming, 2E Introductory Concepts and Techniques Chapter 4 Decision Making and Repetition with Reusable Objects.
Object-Oriented Application Development Using VB.NET 1 Chapter 10 VB.NET GUI Components Overview.
Chapter 5 Introduction To Form Builder. Lesson A Objectives  Display Forms Builder forms in a Web browser  Use a data block form to view, insert, update,
Chapter 15: Exception Handling C++ Programming: Program Design Including Data Structures, Fifth Edition.
Microsoft Visual Basic 2008: Reloaded Third Edition Chapter One An Introduction to Visual Basic 2008.
10 Chapter 101 Using Menus and Validating Input Programming Logic and Design, Second Edition, Comprehensive 10.
 2002 Prentice Hall. All rights reserved. 1 Introduction to the Visual Studio.NET IDE Outline Introduction Visual Studio.NET Integrated Development Environment.
Microsoft Visual C# 2010 Fourth Edition Chapter 3 Using GUI Objects and the Visual Studio IDE.
Microsoft Visual Basic 2012: Reloaded Fifth Edition Chapter One An Introduction to Visual Basic 2012.
Programming Logic and Design Fourth Edition, Comprehensive Chapter 10 Using Menus and Validating Input.
COMPREHENSIVE Excel Tutorial 12 Expanding Excel with Visual Basic for Applications.
Programming Logic and Design Seventh Edition Chapter 12 Event-Driven GUI Programming, Multithreading, and Animation.
Visual Basic.NET Windows Programming
Chapter 1: An Introduction to Visual Basic 2015
Chapter Topics 15.1 Graphical User Interfaces
Chapter 8: Writing Graphical User Interfaces
1. Introduction to Visual Basic
3.01 Apply Controls Associated With Visual Studio Form
Hands-on Introduction to Visual Basic .NET
CIS16 Application Development Programming with Visual Basic
Chapter 15: GUI Applications & Event-Driven Programming
Presentation transcript:

Programming Logic and Design Fourth Edition, Comprehensive Chapter 14 Event-Driven Programming with Graphical User Interfaces

Programming Logic and Design, Fourth Edition, Comprehensive2 Objectives Understand the principles of event-driven programming Describe user-initiated actions and GUI components Design graphical user interfaces Modify the attributes of GUI components List the steps to building an event-driven application

Programming Logic and Design, Fourth Edition, Comprehensive3 Objectives (continued) Understand the disadvantages of traditional error- handling techniques Understand the advantages of the object-oriented technique of throwing exceptions

Programming Logic and Design, Fourth Edition, Comprehensive4 Understanding Event-Driven Programming Command line: screen location where you type entries Operating system: software that runs a computer and manages its resources Icons: pictures representing objects or actions Graphical user interface (GUI): allows users to interact with the operating system by clicking icons to select options

Programming Logic and Design, Fourth Edition, Comprehensive5 Understanding Event-Driven Programming (continued) Event: an occurrence that generates a message to an object Event-based (or event-driven): actions occur in response to user-initiated events When programming with event-driven languages, the emphasis is on: –GUI objects the user can manipulate –Events the user can initiate with those objects

Programming Logic and Design, Fourth Edition, Comprehensive6 Understanding Event-Driven Programming (continued) Procedural programming controls the sequence of events In event-driven programming, the sequence is controlled by the user’s actions Source of the event: a component from which an event is generated Listener: an object that will respond to the event Programmer writes the code that defines what actions are taken when the event occurs

Programming Logic and Design, Fourth Edition, Comprehensive7 User-Initiated Actions and GUI Components Common user-initiated events:

Programming Logic and Design, Fourth Edition, Comprehensive8 User-Initiated Actions and GUI Components (continued) Common GUI components:

Programming Logic and Design, Fourth Edition, Comprehensive9 User-Initiated Actions and GUI Components (continued)

Programming Logic and Design, Fourth Edition, Comprehensive10 User-Initiated Actions and GUI Components (continued) GUI components are usually predefined classes that act like black boxes Programmer must write statements to manipulate GUI objects and take actions when events occur

Programming Logic and Design, Fourth Edition, Comprehensive11 Designing Graphical User Interfaces Design principles for creating a GUI program: –Interface should be natural and predictable –Screen design should be attractive and user-friendly –Allow the user to customize the application if possible –Program should be forgiving –GUI is only a means to an end

Programming Logic and Design, Fourth Edition, Comprehensive12 The Interface Should Be Natural and Predictable Natural: icons that look like their real-world counterparts Predictable: use standard icons for the same purpose Layout of the screen should be predictable –Menu bar at top of screen –First menu item is File

Programming Logic and Design, Fourth Edition, Comprehensive13 The Screen Design Should be Attractive and User-Friendly Attractive interfaces are more likely to be used Fancy fonts and weird color combinations are signs of amateur designers! Unavailable or inappropriate screen or menu options should be disabled, or “grayed out” Screen design should not be distracting

Programming Logic and Design, Fourth Edition, Comprehensive14 It’s Helpful if the User Can Customize Your Applications If possible, allow users to: –Arrange components in the order they want –Change color schemes

Programming Logic and Design, Fourth Edition, Comprehensive15 The Program Should be Forgiving Good programming design: –Always provides an escape route from bad choices –Allow user to back out of “dead end” choices

Programming Logic and Design, Fourth Edition, Comprehensive16 The GUI is Only a Means to an End GUI is only an interface, not the purpose of the program GUI should help make users more productive The GUI design should: –Help users see what options are available –Allow components to be used as normal –Not force the user to figure out how to interact The real work of a GUI program is done after the user makes an action

Programming Logic and Design, Fourth Edition, Comprehensive17 Modifying the Attributes of GUI Components Appearance of GUI components can be changed by modifying the attributes Common types of changes: –Size –Color –Screen location –Font for text in the component –Visible or invisible –Enabled or disabled (dimmed or undimmed)

Programming Logic and Design, Fourth Edition, Comprehensive18 Modifying the Attributes of GUI Components (continued) Different languages have different ways to change attribute values: –With coding statements –By calling a method and passing arguments –Accessing a properties list or table

Programming Logic and Design, Fourth Edition, Comprehensive19 The Steps to Developing an Event-Driven Application Steps to developing any program: –Understand the problem –Plan the logic –Code the program –Translate the program into machine language –Test the program –Put the program into production

Programming Logic and Design, Fourth Edition, Comprehensive20 The Steps to Developing an Event-Driven Application (continued) Three steps added for event-driven programs: –Understand the problem –Create storyboards –Define the objects –Define the connections between screens –Plan the logic –Code the program –Translate the program into machine language –Test the program –Put the program into production

Programming Logic and Design, Fourth Edition, Comprehensive21 Understanding the Problem Developing the application:

Programming Logic and Design, Fourth Edition, Comprehensive22 Creating Storyboards Storyboard: a picture or sketch of the user screen Draw one storyboard cell/frame for each user screen

Programming Logic and Design, Fourth Edition, Comprehensive23 Defining the Objects in an Object Dictionary Object dictionary: –List of objects used in a program –Indicates which screens the objects are used in –Indicates if code or script is associated with the object –May show which variables are affected by an action on the object

Programming Logic and Design, Fourth Edition, Comprehensive24 Defining the Objects in an Object Dictionary (continued)

Programming Logic and Design, Fourth Edition, Comprehensive25 Defining the Connections Between the User Screens Interactivity diagram: shows the relationship between screens in an interactive GUI program

Programming Logic and Design, Fourth Edition, Comprehensive26 Defining the Connections Between the User Screens (continued)

Programming Logic and Design, Fourth Edition, Comprehensive27 Planning the Logic After you have: –Designed the screens –Defined the objects –Defined how screens will connect Then you can plan the logic

Programming Logic and Design, Fourth Edition, Comprehensive28 Planning the Logic (continued)

Programming Logic and Design, Fourth Edition, Comprehensive29 Understanding the Disadvantages of Traditional Error-Handling Techniques Validating user input is a large part of any program GUI data entry objects may help control what a user can enter One error-handling technique was to terminate the program – very unforgiving!

Programming Logic and Design, Fourth Edition, Comprehensive30 Understanding the Disadvantages of Traditional Error-Handling Techniques (continued)

Programming Logic and Design, Fourth Edition, Comprehensive31 Understanding the Disadvantages of Traditional Error-Handling Techniques (continued) Can create an error flag: –Prompt the user to re-enter a valid value –Loop until the data item becomes valid Disadvantages: –Makes module less reusable –Not as flexible as it might be –Only works with interactive programs

Programming Logic and Design, Fourth Edition, Comprehensive32 Understanding the Disadvantages of Traditional Error-Handling Techniques (continued)

Programming Logic and Design, Fourth Edition, Comprehensive33 Understanding the Advantages of Object-Oriented Exception Handling Exception-handling methods: –Used in object-oriented, event-driven programs –Check for and manage errors Exception: an object that represents an error

Programming Logic and Design, Fourth Edition, Comprehensive34 Understanding the Advantages of Object-Oriented Exception Handling (continued) Try: to attempt to execute a module that might throw an error Throw: pass an exception from called module back to the caller Catch: receive an exception from a called module Exception object that is thrown can be any data type

Programming Logic and Design, Fourth Edition, Comprehensive35 Understanding the Advantages of Object-Oriented Exception Handling (continued)

Programming Logic and Design, Fourth Edition, Comprehensive36 Understanding the Advantages of Object-Oriented Exception Handling (continued) try block: contains code that may throw an exception catch block: contains code that executes when an exception is thrown from within a try block

Programming Logic and Design, Fourth Edition, Comprehensive37 Understanding the Advantages of Object-Oriented Exception Handling (continued) catch block –Specifies the data type of the exception it will handle –Executes only when an exception of that data type is thrown in the corresponding try block

Programming Logic and Design, Fourth Edition, Comprehensive38 Understanding the Advantages of Object-Oriented Exception Handling (continued)

Programming Logic and Design, Fourth Edition, Comprehensive39 Understanding the Advantages of Object-Oriented Exception Handling (continued) General principle of exception handling in OOP: –Module that uses data should be able to detect errors, but is not required to handle them –Handling is left to the application that uses the object

Programming Logic and Design, Fourth Edition, Comprehensive40 Summary Event-driven GUI interface allows users to manipulate objects on the screen Source of event: component that generates event Listener: an object interested in an event GUI components are created from predefined classes, and act like black boxes GUI interface should be neutral, predictable, attractive, easy to read, and non-distracting

Programming Logic and Design, Fourth Edition, Comprehensive41 Summary (continued) GUI program should allow user to customize the application and should be forgiving Modify the GUI component attributes to change its appearance Use storyboards to help plan a GUI program Traditional error–handling methods have limitations OOP error handling involves throwing exceptions