Widgets. Widgets Widget Toolkits. User Interface Widget

Similar documents
Widgets. Widgets Widget Toolkits. 2.3 Widgets 1

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. Event Architecture. A pipeline: Event Capture

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

Event Dispatch. Dispatching events to windows and widgets.

CS 4300 Computer Graphics

PROGRAMMING DESIGN USING JAVA (ITT 303) Unit 7

Event Driven Programming

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)

Graphical User Interfaces. Comp 152

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

Swing. By Iqtidar Ali

Layout. Dynamic layout, Swing and general layout strategies

Graphics. Lecture 18 COP 3252 Summer June 6, 2017

GUI Implementation Support

BASICS OF GRAPHICAL APPS

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

Contents Introduction 1

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

Windows and Events. created originally by Brian Bailey

CSE 331 Software Design & Implementation

Introduction to the JAVA UI classes Advanced HCI IAT351

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

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

Sri Vidya College of Engineering & Technology

Graphical User Interfaces (GUIs)

MODEL UPDATES MANIPULATES USER

Model-view-controller View hierarchy Observer

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

GUI Software Architecture

CS11 Java. Fall Lecture 4

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

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

Fall UI Design and Implementation 1

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

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

Programming graphics

GUI Basics. Object Orientated Programming in Java. Benjamin Kenwright

Chapter 6: Graphical User Interfaces

Graphical User Interface (GUI)

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

Chapter 12 GUI Basics

CPS122 Lecture: Graphical User Interfaces and Event-Driven Programming

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!

Object-Oriented Programming Design. Topic : Graphics Programming GUI Part I

Advanced Effects in Java Desktop Applications

Programming Graphical

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

Educational Fusion. Implementing a Production Quality User Interface With JFC

Graphic User Interfaces. - GUI concepts - Swing - AWT

Unit 6: Graphical User Interface

SD Module-1 Advanced JAVA

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

GUI Components: Part 1

SD Module-1 Advanced JAVA. Assignment No. 4

Summary Chapter 25 GUI Components: Part 2

Organization of User Interface Software

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

Programming Languages and Techniques (CIS120)

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...

Original GUIs. IntroGUI 1

Week Chapter Assignment SD Technology Standards. 1,2, Review Knowledge Check JP3.1. Program 5.1. Program 5.1. Program 5.2. Program 5.2. Program 5.

Lecture 9. Lecture

UI Software Organization

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

Is image everything?

GUI Event Handlers (Part I)

Java Swing. based on slides by: Walter Milner. Java Swing Walter Milner 2005: Slide 1

Java: Graphical User Interfaces (GUI)

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

Window Interfaces Using Swing Objects

This page intentionally left blank

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

Layout. Dynamic layout Layout design pattern Layout strategies

Input: Interaction Techniques

2110: GUIS: Graphical User Interfaces

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

Java. GUI building with the AWT

Window Interfaces Using Swing Objects

Java Programming Lecture 6

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

Fall UI Design and Implementation 1

Swing: Building GUIs in Java

Human-Computer Interaction IS4300

GUI Design for Android Applications

Introduction to concurrency and GUIs

Lecture 18 Java Graphics and GUIs

Java IDE Programming-I

Building Graphical User Interfaces. Overview

Swing: Building GUIs in Java

Programming Languages and Techniques (CIS120)

Outline. Topic 9: Swing. GUIs Up to now: line-by-line programs: computer displays text user types text AWT. A. Basics

Jonathan Aldrich Charlie Garrod

CSE 219 COMPUTER SCIENCE III BEHAVIORAL DESIGN PATTERNS SLIDES COURTESY: RICHARD MCKENNA, STONY BROOK UNIVERSITY

Dojo: An Accessible JavaScript Toolkit

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: - appearances: 2.3 Widgets 5 Widget Architecture as MVC perceive present View notify Properties logical device essential geometry Model Change Events express change translate Controller 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 2.3 Widgets 23 Consistency Use a common look and feel Use widgets appropriately 2.3 Widgets 24

Implementation Choices Heavyweight Widgets - OS provides widgets and hierarchical windowing system - Widget toolkit wraps OS widgets for programming language - BWS can dispatch events to a specific widget - Examples: nested X Windows, Java s AWT, OSX Cocoa, standard HTML form widgets, Windows MFC Lightweight Widgets - OS provides a top level window - Widget toolkit draws its own widgets and is responsible for mapping events to their corresponding widgets - Examples: Java Swing, JQuery UI, WIndows WPF 2.3 Widgets 25 Java Abstract Window Toolkit (AWT) Heavyweight toolkit - OS standard widgets, mapped onto the Java language: Button, Canvas, Choice, Frame, Label, List, MenuBar, Panel, PopupMenu, Scrollbar, TextArea, Window - Since BWS is aware of them, can send events directly to them Only components that are supported on most platforms are included, so it s a minimal widget toolkit - the least-common denominator across OSX, Windows, Linux, - so, no Spinner, no combo box, no progress bar, Programmers need to re-create/find unsupported widgets Uses exact OS look and feel 2.3 Widgets 26

Java Swing Widget Toolkit Lightweight Toolkit Widgets are implemented in Java 2D - essentially, custom draw commands in paintcomponent() AWT is still required for Window (OS level) BWS only knows about main window, so widget event dispatch is done in Java Mixing Swing and AWT widgets used to be problematic - Fewer technical problems after Java 6 - AWT rendered by OS, Swing rendered by Java (guess who won) Different Swing Look and Feels - (see SwingThemeDemo.java lecture code) 2.3 Widgets 27 AWT and Swing 2.3 Widgets 28

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 29