Widgets. Widgets Widget Toolkits. 2.3 Widgets 1

Similar documents
Widgets. Widgets Widget Toolkits. User Interface Widget

Widgets. Overview. Widget. Widgets Widget toolkits Lightweight vs. heavyweight widgets Swing Widget Demo

Widget. Widget is a generic name for parts of an interface that have their own behaviour. e.g., buttons, progress bars, sliders, drop-down

Widget Toolkits CS MVC

Event Dispatch. Interactor Tree Lightweight vs. Heavyweight Positional Dispatch Focus Dispatch. 2.4 Event Dispatch 1

Event Dispatch. Interactor Tree Lightweight vs. Heavyweight Positional Dispatch Focus Dispatch. Event Architecture. A pipeline: Event Capture

Event Dispatch. Dispatching events to windows and widgets.

CS 4300 Computer Graphics

PROGRAMMING DESIGN USING JAVA (ITT 303) Unit 7

Event Driven Programming

Layout. Dynamic layout, Swing and general layout strategies

Graphical User Interfaces. Comp 152

GUI Implementation Support

Swing. By Iqtidar Ali

Prototyping a Swing Interface with the Netbeans IDE GUI Editor

Graphics programming. COM6516 Object Oriented Programming and Design Adam Funk (originally Kirill Bogdanov & Mark Stevenson)

BASICS OF GRAPHICAL APPS

Introduction to the JAVA UI classes Advanced HCI IAT351

MODEL UPDATES MANIPULATES USER

Introduction to Graphical Interface Programming in Java. Introduction to AWT and Swing

Graphical User Interface (GUI) components in Java Applets. With Abstract Window Toolkit (AWT) we can build an applet that has the basic GUI

Events. Dispatch, event-to-code binding. Review: Events Defined 1/17/2014. occurrence.

GUI Software Architecture

Today. cisc3120-fall2012-parsons-lectiii.3 2

CS11 Java. Fall Lecture 4

Tool Kits, Swing. Overview. SMD158 Interactive Systems Spring Tool Kits in the Abstract. An overview of Swing/AWT

Chapter 6: Graphical User Interfaces

Graphical User Interfaces (GUIs)

Windows and Events. created originally by Brian Bailey

Chapter 12 GUI Basics

GUI Basics. Object Orientated Programming in Java. Benjamin Kenwright

Graphical User Interface (GUI)

Sri Vidya College of Engineering & Technology

CompSci 125 Lecture 17. GUI: Graphics, Check Boxes, Radio Buttons

Starting Out with Java: From Control Structures Through Objects Sixth Edition

MOBILE COMPUTING 1/20/18. How many of you. CSE 40814/60814 Spring have implemented a command-line user interface?

GUI Event Handlers (Part I)

Graphics. Lecture 18 COP 3252 Summer June 6, 2017

Layout. Dynamic layout Layout design pattern Layout strategies

Unit 6: Graphical User Interface

Layout. Dynamic layout Layout design pattern Layout strategies. 2.6 Layout 2

Introduction to Graphical User Interfaces (GUIs) Lecture 10 CS2110 Fall 2008

GUI Components: Part 1

Fall UI Design and Implementation 1

Original GUIs. IntroGUI 1

GUI in C++ PV264 Advanced Programming in C++ Nikola Beneš Jan Mrázek Vladimír Štill. Faculty of Informatics, Masaryk University.

(Incomplete) History of GUIs

Lab 4. D0010E Object-Oriented Programming and Design. Today s lecture. GUI programming in

Graphic User Interfaces. - GUI concepts - Swing - AWT

Organization of User Interface Software

CS111: PROGRAMMING LANGUAGE II

All the Swing components start with J. The hierarchy diagram is shown below. JComponent is the base class.

Part 3: Graphical User Interface (GUI) & Java Applets

Advanced Java Programming. Swing. Introduction to Swing. Swing libraries. Eran Werner, Tel-Aviv University Summer, 2005

Fall UI Design and Implementation 1

CPS122 Lecture: Graphical User Interfaces and Event-Driven Programming

Programming Languages and Techniques (CIS120)

Java: Graphical User Interfaces (GUI)

Introduction to GUIs. Principles of Software Construction: Objects, Design, and Concurrency. Jonathan Aldrich and Charlie Garrod Fall 2014

Contents Introduction 1

Heavyweight with platform-specific widgets. AWT applications were limited to commonfunctionality that existed on all platforms.

Programming graphics

KF5008 Program Design & Development. Lecture 1 Usability GUI Design and Implementation

Model-view-controller View hierarchy Observer

where are we? ICS 105: Project in HCI ui toolkits what does the toolkit do? model-view-controller model-view-controller lectures

Packages: Putting Classes Together

This page intentionally left blank

Human-Computer Interaction IS4300

Window Interfaces Using Swing Objects

Java IDE Programming-I

CSE 331 Software Design & Implementation

GUI Programming. Chapter. A Fresh Graduate s Guide to Software Development Tools and Technologies

Summary Chapter 25 GUI Components: Part 2

CS 231 Data Structures and Algorithms Fall Event Based Programming Lecture 06 - September 17, Prof. Zadia Codabux

SD Module-1 Advanced JAVA

Jonathan Aldrich Charlie Garrod

Window Interfaces Using Swing Objects

Introduction p. 1 JFC Architecture p. 5 Introduction to JFC p. 7 The JFC 1.2 Extension p. 8 Swing p. 9 Drag and Drop p. 16 Accessibility p.

CS415 Human Computer Interaction

Is image everything?

SD Module-1 Advanced JAVA. Assignment No. 4

Lecture 9. Lecture

Programming Graphical

Mobile Application Development

Table of Contents. Chapter 1 Getting Started with Java SE 7 1. Chapter 2 Exploring Class Members in Java 15. iii. Introduction of Java SE 7...

We will talk about Alt-Tab from the usability perspective. Think about: - Is it learnable? - Is it efficient? - What about errors and safety?

Model-View-Controller

CONTENTS. Chapter 1 Getting Started with Java SE 6 1. Chapter 2 Exploring Variables, Data Types, Operators and Arrays 13

Advanced Effects in Java Desktop Applications

Command-Line Applications. GUI Libraries GUI-related classes are defined primarily in the java.awt and the javax.swing packages.

Outline CSE 3461 F10. What is a Widget? Properties of Widgets. A self-contained screen object Also called a control Examples of widgets:

Topic 9: Swing. Swing is a BIG library Goal: cover basics give you concepts & tools for learning more

Topic 9: Swing. Why are we studying Swing? GUIs Up to now: line-by-line programs: computer displays text user types text. Outline. 1. Useful & fun!

WIMP Elements. GUI goo. What is WIMP?

UI Software Organization

Java Programming Lecture 6

XPToolkit Schedule. Page 1

Graphical User Interface (Part-3) Supplementary Material for CPSC 233

CS11 Java. Fall Lecture 3

Input: Interaction Techniques

Transcription:

Widgets Widgets Widget Toolkits 2.3 Widgets 1

User Interface Widget Widget is a generic name for parts of an interface that have their own behavior: buttons, drop-down menus, spinners, file dialog boxes, progress bars, sliders, widgets also called components, or controls They provide user feedback and capture user input They have a defined appearance They send and receive events Widget from Wow Wow Wubbzy 2.3 Widgets 2

Early User Interface Widgets Macintosh System 5, circa 1987 2.3 Widgets 3

Logical Device A logical device is the essence of what a widget does, its function e.g. logical button device - function: generate pushed event A widget is a logical device with an appearance e.g. widgets based on logical button device - appearances: push button, keyboard shortcut, menu item, 2.3 Widgets 4

Other Logical Devices logical number device - function: adjust a number, generates a changed event - appearances: slider, spinner, numeric textbox, logical boolean device - function: select or unselect, generates a changed event - appearances: radio button, checkbox, toggle 2.3 Widgets 5

Widget Architecture as MVC perceive present View notify Properties logical device Model Change Events express translate Controller change 2.3 Widgets 6

Widget Architecture as MVC widget perceive present View notify Properties logical device essential geometry Model Change Events express translate Controller change 2.3 Widgets 7

ToggleButton Widget Example On ToggleButton Off perceive present View notify ison boolean logical device x, y diameter Model toggleevent express Change translate Controller change No Change 2.3 Widgets 8

ToggleButton.cpp class ToggleButton { ToggleButton(int _x, int _y, void (*_toggleevent)(bool)) { toggleevent = _toggleevent; ison = false;... } // the CONTROLLER void mouseclick(int mx, int my) { float dist = sqrt(pow(mx - x, 2) + pow(my - y, 2)); if (dist < diameter) { toggle(); } }... 2.3 Widgets 9

ToggleButton.cpp (cont d)... // the VIEW void draw() { if (ison) { setforeground(black); XFillArc(...); } else { setforeground(white); XFillArc(...); } } // VIEW "essential geometry" int x; int y; int diameter;... 2.3 Widgets 10

ToggleButton.cpp (cont d) };... // toggle event callback void (*toggleevent)(bool); // the MODEL bool ison; void toggle() { ison =!ison; toggleevent(ison); } 2.3 Widgets 11

ToggleButton.cpp (cont d) bool ispaused = false; // ispaused callback (a simple event handler) void togglepause(bool ison) { ispaused = ison; }... ToggleButton togglebutton(150, 100, &togglepause);...... case ButtonPress: togglebutton.mouseclick(event.xbutton.x, event.xbutton.y); break; if (!ispaused) { // update ball position } togglebutton.draw(); 2.3 Widgets 12

Categorizing and Characterizing Widgets Logical device (button, number, text, choice ) Events the widget generates (action, change, ) Properties to change behaviour and appearance (colour, size, icon, allowable values, ) Can it contain other widgets? (container vs. simple) 2.3 Widgets 13

Simple Widgets Labels and Images - (usually) no model or events - e.g. label, icon, spacer, Button - no model, pushed event - properties: label, size - e.g. button Boolean - true/false model, changed event - e.g. radio button, checkbox, toggle button 2.3 Widgets 14

Radio Button 2.3 Widgets 15

Simple Widgets Number - model: real number, changed event - properties: range, step - e.g. slider, progress bar, scrollbar Text - model: string; changed, selection, insertion events - properties: formatters (numeric, phone number, ) 2.3 Widgets 16

Container Widgets Panel (Pane, Form, Toolbar) - arrangement of widgets - e.g. JPanel, toolbar Tab - choice between arrangements of widgets 2.3 Widgets 17

Container Widgets Menu - hierarchical list of (usually) buttons Choice from a List - list of boolean widgets - e.g. drop-down, combo-box, radio button group, split button 2.3 Widgets 18

Special Value Widgets colour/file/date/time pickers 2.3 Widgets 19

Widget toolkits Also called widget libraries or GUI toolkits or GUI APIs Software bundled with a window manager, operating system, development language, hardware platform Defines a set of GUI components for programmers - Examples: buttons, drop-down menus, sliders, progress bars, lists, scrollbars, tab panes, file selection dialogs, etc. Programmers access these GUI components via an application programming interface (API) 2.3 Widgets 20

Event-driven programming Widget toolkits use event-driven programming model Reactive systems - User action program response - Most of the time the program sits around doing nothing Widget toolkit supports a mechanism for mapping user action on widget to appropriate application code to handle that action 2.3 Widgets 21

Widget Toolkit Design Goals: Complete - GUI designers have everything they need Consistent - Behaviour is consistent across components Customizable - Developer can reasonably extend functionality to meet particular needs of application Meeting these requirements encourages reuse 2.3 Widgets 22

Completeness All you really need are: - Button - Slider - Pulldown menu - Check box - Radio button - Text field - Spinner 2.3 Widgets 23

Widget Choice Use a common look and feel Use widgets appropriately 2.3 Widgets 24

Heavyweight Widgets Underlying platform provides widgets and hierarchical windowing system Widget toolkit wraps platform widgets for programming language The platform (ex. BWS) can dispatch events to a specific widget Examples: Java s AWT, OSX Cocoa, Windows MFC, nested X Windows, standard HTML form widgets Advantages Events generated by user are passed directly to components by the Platform Preserves Platform look and feel Disadvantages Platform-specific programming Multi-platform toolkits tend to be defined as the lowest-common set of components 2.3 Widgets 25

Consistency: Name that Look 1 2 3 4 5 6 CS 349 - Widgets 26

Lightweight Widgets OS provides a top level window Widget toolkit draws its own widgets in the window. Toolkit is responsible for mapping events to their corresponding widgets Examples: Java Swing, JQuery UI, Windows WPF Advantages Can guarantee identical look-and-feel across platforms. Can guarantee consistent widget set on all platforms. (see WidgetDemo.java lecture code) Can implement very light/optimized widgets. Disadvantages Concerns that they appear non-native. Concerns about performance with extra layer of abstraction. 2.3 Widgets 27

WidgetDemo.java Add JLabel, set properties Add JButton, JSlider Create JMenuItems, add to JMenu in a JMenuBar Create JRadioButtons, put into ButtonGroup and JPanel Create events for all widgets to settext in label Set layout manager for JFrame 2.3 Widgets 28