©2007 · Georges Merx and Ronald J. NormanSlide 1 Chapter 7 Interfacing with Users.

Slides:



Advertisements
Similar presentations
Event handling and listeners What is an event? user actions and context event sources and listeners Why should my programs be event- driven? User interaction.
Advertisements

Introduction to Java 2 Programming
Graphic User Interfaces Layout Managers Event Handling.
CMSC 341 Building Java GUIs. 09/26/2007 CMSC 341 GUI 2 Why Java GUI Development? Course is about Data Structures, not GUIs. We are giving you the opportunity.
JAVA API (GUI) Subject:T0934 / Multimedia Programming Foundation Session:1 Tahun:2009 Versi:1/0.
Advanced Swing. Advanced Layout Managers GridBagLayout – Example: Web Browser (Grid Bag Layout)Web Browser (Grid Bag Layout) BoxLayout – Example: Web.
Corresponds with Chapter 12
Event Driven Programming and GUIs Part 3 CS221 – 4/15/09.
Java Programming, 3e Concepts and Techniques Chapter 5 Arrays, Loops, and Layout Managers Using External Classes.
Understanding SWING Architecture CS 4170 UI Design Hrvoje Benko Oct. 9, 2001.
Graphical User Interfaces (GUIs) GUI: An application that uses graphical objects to interact with users GUI applications consist of: –Events: A user or.
Swing CS-328 Dick Steflik John Margulies. Swing vs AWT AWT is Java’s original set of classes for building GUIs Uses peer components of the OS; heavyweight.
1 L48 Advanced GUI Component (3). 2 OBJECTIVES  To use additional layout managers.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved L03 (Chapter 15) Creating.
1 GUI Elements in Java Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
GUI Layout Managers Arkadiusz Edward Komenda. Outline Components and Containers Layout Managers Flow Layout Grid Layout Border Layout Nested Containers.
Chapter 13: Advanced GUIs and Graphics J ava P rogramming: From Problem Analysis to Program Design, From Problem Analysis to Program Design, Second Edition.
Scott Grissom, copyright 2006Ch 11: GUI Slide 1 Graphical User Interfaces (Ch 11) Careful design of a graphical user interface is key to a viable software.
PROGRAMMING REVIEW Lab 2 EECS 448 Dr Fengjun Li and Meenakshi Mishra.
Introduction to Java Swing “We are the sultans of swing” – Mark Knopfler.
20-753: Fundamentals of Web Programming Copyright © 1999, Carnegie Mellon. All Rights Reserved. 1 Lecture 16: Java Applets & AWT Fundamentals of Web Programming.
Chapter 13 Advanced GUIs and Graphics. Chapter Objectives Learn about applets Explore the class Graphics Learn about the class Font Explore the class.
Intro to Java 2 By Geb Thomas Based on the Java TutorialJava Tutorial.
Java Software Solutions Lewis and Loftus Chapter 10 1 Copyright 1997 by John Lewis and William Loftus. All rights reserved. Graphical User Interfaces --
Java Programming: From Problem Analysis to Program Design, 4e Chapter 12 Advanced GUIs and Graphics.
1 CSC111H Graphical User Interfaces (GUIs) Introduction GUIs in Java Understanding Events A Simple Application The Containment Hierarchy Layout Managers.
Object Oriented Programming Ders 11: Interfaces Mustafa Emre İlal
Java GUI CSCE 190 – Java Instructor: Joel Gompert Mon, July 26, 2004.
Introduction to Swing Components Chapter 14.  Part of the Java Foundation Classes (JFC)  Provides a rich set of GUI components  Used to create a Java.
Java Programming: Advanced Topics 1 Common Elements of Graphical User Interfaces Chapter 6.
Graphical User Interface Components Chapter What You Will Learn Text Areas Text Areas Sliders Sliders Menus Menus –With frames –Pop up menus Look.
Ch 3-4: GUI Basics Java Software Solutions Foundations of Program Design Sixth Edition by Lewis & Loftus Coming up: GUI Components.
 2002 Prentice Hall, Inc. All rights reserved Introduction Graphical User Interface (GUI) –Gives program distinctive “look” and “feel” –Provides.
1 CSC111H Graphical User Interfaces (GUIs) Introduction GUIs in Java Understanding Events A Simple Application The Containment Hierarchy Layout Managers.
– Advanced Programming P ROGRAMMING IN Lecture 21 Introduction to Swing.
1 Outline 1 Introduction 2 Overview of Swing Components 3 JLabel 4 Event Handling 5 TextFields 6 How Event Handling Works 7 JButton 8 JCheckBox and JRadioButton.
Graphics and Event-Driven Programming in Java John C. Ramirez Department of Computer Science University of Pittsburgh.
12.1 CSC 123 Systems Analysis & Design Part IV: The Essentials of Design Chapter 12 Designing Effective Input.
Timer class and inner classes. Processing timer events Timer is part of javax.swing helps manage activity over time Use it to set up a timer to generate.
Java Applets: GUI Components, Events, Etc. Ralph Westfall June, 2010.
Object-Oriented Program Development Using Java: A Class-Centered Approach, Enhanced Edition.
Computer Science [3] Java Programming II - Laboratory Course Lab 4: Common GUI Event Types and Listener Interfaces Layout Mangers Faculty of Engineering.
1 / 67 COP 3503 FALL 2012 SHAYAN JAVED LECTURE 14 Programming Fundamentals using Java 1.
Lec.10 (Chapter 8 & 9) GUI Jiang (Jen) ZHENG June 27 th, 2005.
AGDER COLLEGEFACULTY OF ENGINEERING & SCIENCE GUI Components ikt403 – Object-Oriented Software Development.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 15 Creating User.
CS-1020 Dr. Mark L. Hornick 1 Event-Driven Programming.
CHAPTER:07 JAVA IDE PROGRAMMING-II Prepared By Prepared By : VINAY ALEXANDER ( विनय अलेक्सजेंड़र ) PGT(CS),KV JHAGRAKHAND.
The Abstract Window Toolkit (AWT) supports Graphical User Interface (GUI) programming. AWT features include: a rich set of user interface components; a.
Swinging in Your Java Playground. Background Swing is a part of the Java Foundation Classes (JFC). The JFC is made up of features intended to give a programmer.
Review_6 AWT, Swing, ActionListener, and Graphics.
CPSC 233 Tutorial Xin Apr 6, Reading files An example available on my website pages.cpsc.ucalgary.ca/~liuxin.
Creating User Interfaces Event-Driven Programming.
 Figure illustrates a hierarchy containing many event classes from the package java.awt.event.  Used with both AWT and Swing components.  Additional.
Chapter 10 - Writing Graphical User Interfaces1 Chapter 10 Writing Graphical User Interfaces.
1 Lecture 8: User Interface Components with Swing.
Introduction to GUI in 1 Graphical User Interface 3 Nouf Almunyif.
Introduction to GUI Programming in Java: Frames, Simple Components, and Layouts.
Chapter 9: Graphical User Interfaces
Christopher Budo, Davis Nygren, spencer franks, Luke miller
Advanced User Interfaces
Java GUI.
University of Central Florida COP 3330 Object Oriented Programming
Chap 7. Building Java Graphical User Interfaces
Layout Managers A layout manager is an object that determines the way that components are arranged in a container There are several predefined layout managers.
Chapter 13: Advanced GUIs and Graphics
Graphical User Interfaces -- Introduction
Advanced GUIs and Graphics
Graphical User Interface
Presentation transcript:

©2007 · Georges Merx and Ronald J. NormanSlide 1 Chapter 7 Interfacing with Users

©2007 · Georges Merx and Ronald J. NormanSlide 2 Agenda GUI support –awt –javax.swing GUI design principles Model-view-controller pattern

©2007 · Georges Merx and Ronald J. NormanSlide 3 GUI Design Best Practice Software engineering best practice: design the program user interface after the functional components have been determined from a work process perspective

©2007 · Georges Merx and Ronald J. NormanSlide 4 GUI Design Principles (1) Use industry and de facto standards where available. If a program is written for a particular platform, then favor the accepted visualization standards for that platform; otherwise either provide an adaptable GUI, or use a platform-neutral GUI like Sun’s METAL look- and-feel. Use familiar, consistently named user interface artifacts; examples: “OK” and “Cancel” buttons with proper short cuts and organized with correct tab sequences; consistent menu layouts and menu selections with familiar, consistent shortcuts; tooltips for each artifact; well-organized, naturally sequenced display and interaction components. Activate only logically usable elements – inactivate components, which should logically not be accessible, given the sequence in the workflow in process. Inactivation may be implemented as graying out or simply not showing a user interface component that has no function in the current context.

©2007 · Georges Merx and Ronald J. NormanSlide 5 GUI Design Principles (2) Provide context-specific online help for all interactions, components, and functions. Implement function key F1 to access the program Help function and Shift-F1 to change the cursor to a question mark for context-specific help queries. Use GUI artifacts conservatively: avoid font changes, colors, icons, and images, unless there is a clear, justifiable purpose for overriding the default look and behaviors. Use the available screen “real estate” sparingly; don’t waste space, but organize artifacts logically and consistently according to their work process function and sequence. Avoid cluttering containers; include a maximum of seven elements in a single container (“Miller’s Law”), whenever possible; use labeled containers (frames) to group related GUI elements. Ensure that all GUI components can be localized for other languages and cultures. Account for differences in script direction in certain languages, if necessary.

©2007 · Georges Merx and Ronald J. NormanSlide 6 Bad GUI Example Colors Consistency Fonts Illustration relevance Button position Use of screen real estate

©2007 · Georges Merx and Ronald J. NormanSlide 7 Model-View-Controller Architectural design pattern –Model: the model component of the pattern represents the business rules and algorithms, the core functional components –View: the view component provides the user interface and interaction –Controller: the controller component governs the program navigation functions

©2007 · Georges Merx and Ronald J. NormanSlide 8 Event-Handling Model Two entry points - Start-up - Event occurrence

©2007 · Georges Merx and Ronald J. NormanSlide 9 awt Library The awt library contains the core components for creating user interfaces and for displaying graphics and images –Some components are for display purposes only, such as labels –Others are interactive: this means that they generate events when activated by the user AWTEvent is the parent class for all possible awt events –awt also includes the Container class which provides a receptacle for other awt components, including layout managers, which help position components in a graphical environment

©2007 · Georges Merx and Ronald J. NormanSlide 10 swing Library swing components extend the core awt graphical components They are easily identified, as they all start with a “J,” as in JRadioButton, JLabel, and JPanel They are “lightweight,” meaning that they do not directly interface with underlying operating system calls, and are implemented entirely in Java, making them independent of the underlying operating environment and improving the portability of the resulting application They provide the typical application with a way to interface with users using well-recognized graphical interface components

©2007 · Georges Merx and Ronald J. NormanSlide 11 GUI Elements Labels –JLabel Buttons –JButton Text Fields –JTextField Text Areas –JTextArea Check Boxes –JCheckBox Radio Buttons –JRadioButton Choice Lists –JComboBox –JList –Multiple-selection lists Scroll Bars –JScrollPane Other –JPopupMenus

©2007 · Georges Merx and Ronald J. NormanSlide 12 Platform Look-and-Feel UIManager. getSystemLookAndFeelClassName() retrieves the look-and-feel of the current operating platform and allows the programmer to let the program dynamically set its look-and-feel according to the platform on which it is running at this time

©2007 · Georges Merx and Ronald J. NormanSlide 13 Container Hierarchy

©2007 · Georges Merx and Ronald J. NormanSlide 14 Layout Managers Java layout managers provide for the logical grouping of components, depending on the intended functional layout. The following layout managers are among those available: –Flow layout –Border layout –Box layout –Card layout –Grid layout –GridBag layout

©2007 · Georges Merx and Ronald J. NormanSlide 15 Example: Flow Layout

©2007 · Georges Merx and Ronald J. NormanSlide 16 Example: Border Layout

©2007 · Georges Merx and Ronald J. NormanSlide 17 Example: Grid Layout

©2007 · Georges Merx and Ronald J. NormanSlide 18 Example: GridBag Layout

©2007 · Georges Merx and Ronald J. NormanSlide 19 GridBag Parameters gridx - specifies the cell containing the leading edge of the component gridy - specifies the cell at the top of the component gridwidth - specifies the number of cells in a row gridheight - specifies the number of cells in a column weightx - specifies how to distribute extra horizontal space weighty - specifies how to distribute extra vertical space –anchor - determines where to place the component: the absolute values are: CENTER, NORTH, NORTHEAST, EAST, SOUTHEAST, SOUTH, SOUTHWEST, WEST, NORTHWEST ; the relative values are: PAGE_START, PAGE_END, LINE_START, LINE_END, FIRST_LINE_START, FIRST_LINE_END, LAST_LINE_START, LAST_LINE_END ; the default value is CENTER fill - determines whether to resize the component, and if so, how: NONE, HORIZONTAL, VERTICAL, BOTH insets (top, left, bottom, right) - the space that a container must leave at each of its edges ipadx - specifies the internal padding of the component in the horizontal direction ipady - specifies the internal padding of the component in the vertical direction

©2007 · Georges Merx and Ronald J. NormanSlide 20 Event Listeners … implements ActionListener –Integrated –Inner class –Separate class Interaction TypeType of Listener Button click, Return pressed in text field, or menu item selection ActionListener Main window close button activated WindowListener Mouse button click while the cursor is over a component MouseListener Mouse moved over a component MouseMotionListener Component becomes visible ComponentListener Component gets keyboard focus FocusListener A table or list selection changes ListSelectionListener

©2007 · Georges Merx and Ronald J. NormanSlide 21 Types of Applications Business, entertainment, scientific/technical, …

©2007 · Georges Merx and Ronald J. NormanSlide 22 Position in Process It is important to understand the Testing Phase as a formal phase of testing at this stage in the development process, not as the first instance of testing overall: testing activities should permeate the development process from the earliest activities of concept validation to the verification of ongoing maintenance activities after the product is generally released

©2007 · Georges Merx and Ronald J. NormanSlide 23 Test Coverage Example: Electronic Timecard Application

©2007 · Georges Merx and Ronald J. NormanSlide 24 Customer Testing Alpha testing –Initial exposure to customers of some functions Beta testing –Initial customer implementation – productive use