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

Similar documents
CSE 3461 W08. Types of Text Components. Labels: Example. Labels

Outline. Widgets. Categories of Widgets. What is a Widget?

CS111: PROGRAMMING LANGUAGE II

Graphical User Interfaces. Comp 152

PROGRAMMING DESIGN USING JAVA (ITT 303) Unit 7

Module 5 The Applet Class, Swings. OOC 4 th Sem, B Div Prof. Mouna M. Naravani

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

Human-Computer Interaction IS4300

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

Graphical Applications

COSC 123 Computer Creativity. Graphics and Events. Dr. Ramon Lawrence University of British Columbia Okanagan

Graphical User Interface (GUI)

Chapter 6: Graphical User Interfaces

BASICS OF GRAPHICAL APPS

Control Flow: Overview CSE3461. An Example of Sequential Control. Control Flow: Revisited. Control Flow Paradigms: Reacting to the User

Programming graphics

Containers. Atomic Components. Containment Hierarchy. Example Example 3.3 (revisited) Example DemoSwing.java

GUI Basics. Object Orientated Programming in Java. Benjamin Kenwright

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

WIMP Elements. GUI goo. What is WIMP?

Widgets. Widgets Widget Toolkits. 2.3 Widgets 1

Human-Computer Interaction IS4300

Chapter 12 GUI Basics

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

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

Java IDE Programming-I

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

Chapter 17 Creating User Interfaces

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

Human-Computer Interaction IS4300

Interface Design Issues Lecture 8

CS 209 Spring, 2006 Lab 8: GUI Development Instructor: J.G. Neal

CS 4300 Computer Graphics

Systems Programming Graphical User Interfaces

Unit 6: Graphical User Interface

Widgets. Widgets Widget Toolkits. User Interface Widget

Graphics. Lecture 18 COP 3252 Summer June 6, 2017

GUI Software Architecture

Handout 14 Graphical User Interface (GUI) with Swing, Event Handling

SD Module-1 Advanced JAVA

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!

SD Module-1 Advanced JAVA. Assignment No. 4

2110: GUIS: Graphical User Interfaces

Sri Vidya College of Engineering & Technology

GUI Components: Part 1

CSE Lab 8 Assignment Note: This is the last lab for CSE 1341

Contents Chapter 1 Introduction to Programming and the Java Language

To gain experience using GUI components and listeners.

Marcin Luckner Warsaw University of Technology Faculty of Mathematics and Information Science

CSE 143. Event-driven Programming and Graphical User Interfaces (GUIs) with Swing/AWT

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

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

Introduction to Microsoft PowerPoint 2010

Swing. By Iqtidar Ali

Single Menus No other menus will follow necessitating additional user choices

Graphical User Interface (GUI)

Forms/Distribution Acrobat X Professional. Using the Forms Wizard

10 Inventions on Command Buttons in a Graphical User Interface

CS 251 Intermediate Programming GUIs: Components and Layout

Oskari UX Guide Cybercom Finland Oy

Graphical User Interfaces. Swing. Jose Jesus García Rueda

Introduction to the JAVA UI classes Advanced HCI IAT351

Jonathan Aldrich Charlie Garrod

Overview. Lecture 7: Inheritance and GUIs. Inheritance. Example 9/30/2008

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.

Chapter 4. Swing 18 marks

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

Java Programming Lecture 6

Interaction Techniques. SWE 432, Fall 2016 Design and Implementation of Software for the Web

CS Exam 1 Review Suggestions

Graphic User Interfaces. - GUI concepts - Swing - AWT

Welcome to CIS 068! 1. GUIs: JAVA Swing 2. (Streams and Files we ll not cover this in this semester, just a review) CIS 068

Chapter 12 Advanced GUIs and Graphics

Excel Level 1

Graphical User Interface. GUI in MATLAB. Eng. Banan Ahmad Allaqta

Fall UI Design and Implementation 1

CPS122 Lecture: Graphical User Interfaces and Event-Driven Programming

GUI Components Continued EECS 448

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

CSE 1325 Project Description

Computer Basics Microsoft Windows CB 200

Access: Printing Data with Reports

Goals. Lecture 7 More GUI programming. The application. The application D&D 12. CompSci 230: Semester JFrame subclass: ListOWords

Fall UI Design and Implementation 1

Packages: Putting Classes Together

DEMYSTIFYING PROGRAMMING: CHAPTER SIX METHODS (TOC DETAILED) CHAPTER SIX: METHODS 1

Introduction to Microsoft Word 2010

Graphics User Defined Forms, Part I

Introduction to Microsoft Word 2010

MICROSOFT POWERPOINT

Chapter 7: A First Look at GUI Applications

Frames, GUI and events. Introduction to Swing Structure of Frame based applications Graphical User Interface (GUI) Events and event handling

Interaction Techniques. SWE 432, Fall 2017 Design and Implementation of Software for the Web

ARCHER Metadata Schema Editor. User Guide METADATA EDITOR. Version: 1.1 Date: Status: Release

5. In JAVA, is exception handling implicit or explicit or both. Explain with the help of example java programs. [16]

Creating a PowerPoint Presentation

Human-Computer Interaction. Chapter 2. What is HCI?

Event Dispatch. Dispatching events to windows and widgets.

Lava New Media s CMS. Documentation Page 1

Transcription:

CSE 3461 F10 Widgets Outline What is a widget? Buttons Combo boxes Text components Message boxes 2 What is a Widget? Properties of Widgets A self-contained screen object Also called a control Examples of widgets: buttons, check boxes, lists, scrollbars A widget is usually manipulable it has some behaviour, meaning that it responds to the user s actions on them visually, by changing their appearance auditorially, by producing a sound Widgets are used for both input and output For input: user provides information to application, specifies commands to be performed For output: application provides information to user (such as the application status) A widget may contain other widgets 3 4

Widgets are Important Using Widgets Widgets: are the most obvious visual contribution of GUIs are the basic building blocks of graphical user interfaces (GUIs) provide a means of communication between users and software can make use of pre-defined widgets or create new ones a set of pre-defined widgets is included in the user interface toolkit (such as Swing) sometimes referred to as the set of canned controls user interface toolkit also provides: a mechanism to display widgets (layout management) a means to design new widgets 5 6 Using Widgets Design questions what widget (or set of widgets) is appropriate for this task? what layout is appropriate for these widgets given the available screen real estate Is this widget intuitive to use? does it make use of metaphors of physical controls from the real-world? Outline What is a widget? Buttons Text components Combo boxes Message boxes 7 8

Imperative Controls Push Buttons typically, imperative control that says: take this action and take it immediately the recipient of the action might be already implied e.g., the recipeint of the close on the toolbar is always the toolbar s window the recipient might be modifiable e.g., the recipient of the bold command in a word processing application has a default recipient, but it can be changed imperative control usually has a <verb> or a <verb> <noun> structure The most common type of button Identified by visual features that suggest pressability simulated 3D raised aspect shadow on right and bottom; highlight on top and left shows whether the button is raised or indented buttons might also be painted on the screen they don t actually move when clicked this provides poor visual information 9 10 Push Buttons Examples of Push Buttons A button is pushed to invoke a command with mouse: command executes as soon as the user clicks (a mouse click is the sum of mouse pressed and released; as opposed to mouse press or mouse release) ActionListener keyboard: button needs focus, command executes with key press (as opposed to key release) Button needs to indicate to the semantics of the command that it invokes it can do this with an icon, text, or both 11 Grouping Menu Toolbar Push button Push button Push button 12

Three Devices for Organizing Push Buttons Groupings: one or more buttons in proximity meaning signaled by text or icon Menus: a collection of buttons in a list the list appears and disappears dependent upon a button action meaning typically signaled by text or icon relative position in list carries meaning too Three Devices for Organizing Push Buttons Toolbars: a collection of buttons, typically organized horizontally the collection is persistent appropriate for commonly used functions (we ll contrast later with menus) meaning typically signaled by an icon text is less opaque, but this is a compromise to cope with reduced screen real estate 13 14 Butcons Examples butcon = half button, half icon used in toolbars clues about its pressability removed information that it is pressable becomes apparent only when pointed at butcons are more difficult than buttons for newcomers In theory, butcons easy to use: always visible (therefore easy to memorize) requires less time, dexterity than drop-down menu inextricably linked to toolbars make use of icons, which can be difficult to decipher ToolTips (rollovers) are a solution to this problem DemoBasicButton DemoBasicV4 15 16

Examples Examples DemoIconButton DemoButtonMnemonic DemoDisabledButton 17 18 Selection Control Radio Buttons DemoButtons Push button Radio button Check box Modal button Selection Controls Used to present a set of mutually-exclusive options (the domain of options) Come in groups of two or more a single radio button is undefined Require a substantial amount of screen real estate this use of space must be justified E.g., it is necessary to show the user the fill set of available choices 19 20

Radio Buttons Radio Button Example The domain of options must be: finite small mutually exclusive The name radio button is derived from the selector buttons used to select pre-set radio stations Three mutually-exclusive options 21 22 Radio Button Example Check boxes In DemoButtons smallbutton = new JRadioButton("Small"); mediumbutton = new JRadioButton("Medium"); largebutton = new JRadioButton("Large"); mediumbutton.setselected(true); need to create a multiple-exclusion scope for this set of buttons: ButtonGroup sizegroup = new ButtonGroup(); sizegroup.add(smallbutton); sizegroup.add(mediumbutton); sizegroup.add(largebutton); One of the first visual controls invented Used to select or deselect an option The check mark provides feedback Primarily text-based the graphic supports the text, not the other way around need to add each button to an intermediate container (not the group) need to register an ActionListener on each button 23 24

push button butcons checkbox?? The push button evolved into the butcon its text was replaced with an icon it was migrated on the toolbar What is the equivalent for a check box? if we press a button and it stays recessed ( pushed in ) the button latches this is the same as a check box a latching butcon is equivalent to a checkbox allows us to dispense with text Check boxes Checkboxes are appropriate when: the feature or characteristic has precisely two states (e.g., lightbulb = on off) States are appropriately described as being enabled / disabled or on / off Checkboxes are inappropriate when: the feature or characteristic has more than two states (e.g., season = spring summer autumn winter) enabled/on and disabled/off are inappropriate descriptions of the states (e.g., gender = male female) 25 26 Check box Example Check box Example In DemoButtons italiccheckbox = new JCheckBox("Italic"); boldcheckbox = new JCheckBox("Bold"); Checked = Enable show windows in taskbar Unchecked = Disable show windows in taskbar need to add each check box to an intermediate container; don t need ButtonGroup, like radio buttons need to register an ItemListener on each button need to implement the method itemstatechanged, invoke the method isselected() on the check box instance 27 28

Modal Buttons Modal Button Example Also called flip-flop button Used to select from multiple options A hybrid of a push button and a radio button Looks like a push button When you push it, the selected option changes Should the user interpret the button text as a description of the currently-selected option a description of the option that will be selected if the button is pushed Need to spell it out clearly In DemoButtons showhidebutton = new JToggleButton("Hide"); The text on the button is the button s action command register an ActionListener on the button all instances of ActionEvent that are generated by the toggle button have an associated action command use the method getactioncommand() to determine what it is 29 30 Java s Button Classes Outline AbstractButton JButton JCheckBoxMenuItem JRadioButtonMenuItem JToggleButton Can be included in a menu What is a widget? Buttons Combo boxes Text components Message boxes need to be added to a ButtonGroup in order to implement mutual exclusivity JCheckBox JRadioButton 31 32

Selection Control, Part II The Solution is to Use Combo Boxes Consider the interface to DemoButtons Suppose we want to present a variety of font sizes, and a variety of font types? DemoComboBox 33 Combo box Combo box 34 Combo Boxes Combo Box Example An alternative to radio buttons Appropriate when we have a large number of mutually-exclusive options Advantage over radio buttons More choices can be displayed in less screen space Disadvantage over radio buttons Choices are not displayed until combo box is selected In DemoComboBox final String[] SZ = { "10", "14", "18", "22", "26", "32", "38", "48" }; sizecombo = new JComboBox(SZ); fontcombo = new JComboBox(); for fontcombo, need to add the items to the list for (int i = 0; i < fontlist.length; ++i) fontcombo.additem(fontlist[i].getname()); register an ActionListener on each combo box selections from the list will generate an ActionEvent use the method getselecteditem() to determine which list element was selected 35 36

Outline What is a widget? Buttons Combo boxes Text components Message boxes Types of Text Components Output components cannot be edited Labels, Labeled borders (JLabel, TitledBorder) Tool tips, Message Boxes Input/output components can be edited Text fields, Text areas, Editable combo boxes Dialog boxes 37 38 Labels: Example Labels Label Combo box Label Modal button Create using JLabel Do not react to input events, cannot get keyboard focus Used to display information in particular, placed adjacent to a component that has a keyboard alternative but can t display it Position is determined by Layout Manager Advantage: The information it provides can be useful; aid user s performance of task Disadvantage: Uses screen real estate Poor wording may be worse than none at all 39 40

Labeled Borders: Example Labeled Borders Labeled border This group pertains to Colors Labeled border This group pertains to Links The setborder method is defined for all instances of JComponent Used to create visual clue about groupings A label for the grouping is optional The parameter is an instance of a Border Border is an interface AbstractBorder is an abstract class that implements it TitleBorder extends AbstractBorder E.g., in DemoButtons: JPanel sizegrouppanel = new JPanel(); sizegrouppanel.setborder( new TitledBorder(new EtchedBorder(), "Size")); 41 42 Quick Note About Groupings Text Fields and Text Areas Grouping can reduce cognitive load E.g., consider 12 components: With borders around each of 3 groupings, each with 4 components, the user identifies the group first, then the item within the group (two-step process) Without grouping, user must locate item from among 12 items (this is more difficult!) Grouping can have disadvantages: Uses screen real estate Organization of components requires knowledge of task domain Poor grouping may be worse than none at all 43 Different types: Text Field: single line Text Area: multiple lines The abstract class JTextComponent has the subclasses JTextField, JTextArea Challenges for design: How to validate the text that has been input? How to navigate within and between text elements? 44

Editable Combo Boxes Navigation Similar to a combo box, except that user may also enter text directly Same challenges as text fields and areas validation, navigation Editable and non-editable combo boxes are both instantiated from JComboBox use the methods: seteditable(true), seteditable(false) All components have a focus state The possible focus states are in focus or out of focus For a key press to affect a component, the component must have focus Visual clues are given to show which component has focus I-beam cursor appears, special highlighting Every time the focus changes, a FocusEvent is generated a component loses focus, another gains focus, 45 46 Navigation A component generally gains the focus by the user: clicking it tabbing to it, or otherwise interacting with a component. A component can also be given the focus programmatically e.g., a component can request the focus when its containing frame or dialog is made visible The focus traversal policy determines the order in which a group of components are navigated DemoLookAndFeel.java Metal (java) Motif Windows 47 48

Analysis Exercise How might the organization of these widgets be improved? Outline What is a widget? Buttons Combo boxes Text components Message boxes 49 50 Message Box: Example Message Boxes Dialog box Invalid input Message box 51 A message box (aka dialog box) is a popup window Primary purpose is to govern the interaction presents a text message to the user seeks input for confirmation (and to close the box) Functions to: Notify the user of a problem (e.g., invalid choice) Notify the user of potentially destructive outcome (e.g., overwrite a file) Provide information 52

Message Boxes (2) Advantage Comprehensive messages are possible (unlike tool tips) Disadvantage Slows interaction (because underlying thread is halted until confirmation is received) Behaviour of Message Boxes Message boxes demand immediate attention can t close the message box (user is required to make a choice or to provide confirmation) user is not able to make use of other widgets 53 54 Input-Handling Techniques Example 1. For actions with serious consequences, require an explicit button click or key press before proceeding (pressing Enter does not result in a default action) 2. For invalid input, provide feedback (e.g., alarm tone or visual feedback) 3. Take advantage of user consistency (e.g., change the position of buttons from one invocation to the next) 55 Button positions change from one invocation to next Hitting ENTER produces 56

Example 4.6 DemoMessageBox.java 57