(Incomplete) History of GUIs

Similar documents
Graphical User Interfaces (GUIs)

Graphic User Interfaces. - GUI concepts - Swing - AWT

Introduction to the JAVA UI classes Advanced HCI IAT351

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

G51PGP Programming Paradigms. Lecture 008 Inner classes, anonymous classes, Swing worker thread

Example Programs. COSC 3461 User Interfaces. GUI Program Organization. Outline. DemoHelloWorld.java DemoHelloWorld2.java DemoSwing.

GUI Program Organization. Sequential vs. Event-driven Programming. Sequential Programming. Outline

CSEN401 Computer Programming Lab. Topics: Graphical User Interface Window Interfaces using Swing

Graphical User Interface (GUI)

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

1. Swing Note: Most of the stuff stolen from or from the jdk documentation. Most programs are modified or written by me. This section explains the

EPITA Première Année Cycle Ingénieur. Atelier Java - J5

Graphical User Interface (GUI)

Graphical User Interfaces 2

Computer Science 210: Data Structures. Intro to Java Graphics

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

Packages: Putting Classes Together

Java: Graphical User Interfaces (GUI)

Graphical User Interfaces 2

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

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

Graphical User Interfaces 2

Original GUIs. IntroGUI 1

Chapter 8. Java continued. CS Hugh Anderson s notes. Page number: 264 ALERT. MCQ test next week. This time. This place.

Java continued. Chapter 8 ALERT ALERT. Last week. MCQ test next week. This time. This place. Closed book. Assignment #2 is for groups of 3

Widget Toolkits CS MVC

CS108, Stanford Handout #22. Thread 3 GUI

Chapter 1 GUI Applications

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

User interfaces and Swing

Swing from A to Z Some Simple Components. Preface

G51PRG: Introduction to Programming Second semester Applets and graphics

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

Programming Languages and Techniques (CIS120e)

Programming Language Concepts: Lecture 8

GUI Implementation Support

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

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

Java Swing Introduction

Graphical Interfaces

The JFrame Class Frame Windows GRAPHICAL USER INTERFACES. Five steps to displaying a frame: 1) Construct an object of the JFrame class

Object-Oriented Programming: Revision. Revision / Graphics / Subversion. Ewan Klein. Inf1 :: 2008/09

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

Lecture 5: Java Graphics

Lecture 9. Lecture

CS 251 Intermediate Programming GUIs: Components and Layout

CS11 Java. Fall Lecture 4

GUI Basics. Object Orientated Programming in Java. Benjamin Kenwright

Swing from A to Z Using Focus in Swing, Part 2. Preface

Java Concurrency in practice Chapter 9 GUI Applications

Java Graphical User Interfaces AWT (Abstract Window Toolkit) & Swing

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

Building Graphical User Interfaces. GUI Principles

Java Programming Lecture 6

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

Building a Java First-Person Shooter

1.00 Lecture 14. Lecture Preview

GUI DYNAMICS Lecture July 26 CS2110 Summer 2011

Graphical Interfaces

Swing: Building GUIs in Java

Programming Languages and Techniques (CIS120)

Jonathan Aldrich Charlie Garrod

UI Software Organization

Widgets. Widgets Widget Toolkits. 2.3 Widgets 1

Lecture 3: Java Graphics & Events

Swing: Building GUIs in Java

Introduction to concurrency and GUIs

Quality Assurance User Interface Modeling

Window Interfaces Using Swing Objects

G51PGP Programming Paradigms. Lecture 009 Concurrency, exceptions

CS 2113 Software Engineering

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

CS 251 Intermediate Programming GUIs: Event Listeners

Graphic Interface Programming II Events and Threads. Uppsala universitet

Agenda. Container and Component

Block I Unit 2. Basic Constructs in Java. AOU Beirut Computer Science M301 Block I, unit 2 1

GUI Software Architecture

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

GUI Event Handlers (Part I)

TYPES OF INTERACTORS Prasun Dewan Department of Computer Science University of North Carolina at Chapel Hill

SD Module-1 Advanced JAVA

Class 14: Introduction to the Swing Toolkit

SD Module-1 Advanced JAVA. Assignment No. 4

Beyond CSE143. What s Left To Do? Templates. Using Templates. A Template Class. A Problem with Reusing Code CSE 143

Graphical interfaces & event-driven programming

Building Graphical User Interfaces. Overview

Window Interfaces Using Swing Objects

CSE 331 Software Design & Implementation

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

CSC207 Week 4. Larry Zhang

PROGRAMMING DESIGN USING JAVA (ITT 303) Unit 7

INTRODUCTION TO (GUIS)

Systems Programming Graphical User Interfaces

CSE 331 Software Design & Implementation

Java & Graphical User Interface II. Wang Yang wyang AT njnet.edu.cn

1.00/1.001 Introduction to Computers and Engineering Problem Solving Spring Quiz 2

Overview. Building Graphical User Interfaces. GUI Principles. AWT and Swing. Constructing GUIs Interface components GUI layout Event handling

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

Java. GUI building with the AWT

Graphical User Interface (GUI)

Transcription:

CMSC 433 Programming Language Technologies and Paradigms Spring 2004 Graphical User Interfaces April 20, 2004 (Incomplete) History of GUIs 1973: Xerox Alto 3-button mouse, bit-mapped display, windows 1981: Xerox Star Double-clicking, overlapping windows, dialogs 1983: Apple Lisa Pull-down menus and menu bars 1984: Apple Macintosh, X Windows 1985: Microsoft Windows (from http://toastytech.com/guis/guitimeline.html) 2 1

Why a GUI Toolkit/API? Easier to build GUIs Consistency of interface Among applications Between platforms (in Java) 3 GUI Basics Interface consists of many components Windows, menus, buttons User can perform variety of operations Move window Click button Press key These are events 4 2

A Note on AWT versus Swing Abstract Window Toolkit (AWT) Original Java GUI Still supported, but being replaced Swing -- souped-up AWT Pluggable look-and-feel More, better widgets AWT class X has corresp. Swing class JX E.g. Button vs. JButton 5 Creating Components Components are the usual widgets JButton, JPopupMenu, JScrollBar Components know how to draw themselves But they (generally) don t say where they are In Swing, components live in containers JFrame, JDialog, JApplet Containers decide how to layout components Various layout algorithms 6 3

Observer pattern 7 Programming with Events Initialize objects Create everything on the screen Register your event handlers (observers) Then toolkit takes over with event loop while (true) { e = getevent(); findeventhandler(e).actionperformed(e); } 8 4

Adding Observers (Listeners) Components have a set of listeners void addactionlistener(actionlistener l) void addkeylistener(keylistener l) void addmouselistener(mouselistener l) Possible listeners vary with component 9 Listener Interfaces public interface ActionListener { void actionperformed(actionevent e); } public interface MouseInputListener { void mouseclicked(mouseevent e); void mouseentered(mouseevent e); void mousepressed(mouseevent e);... } 10 5

Events Events objects contain the detailed info public class MouseEvent {... int getclickcount(); Point getpoint(); } Tradeoff between number of event classes and amount of info in each event 11 SwingApplication.java (Optional) Step 1: Install look and feel public static void main(string[] args) { try { UIMananger.setLookAndFeel( UIManager.getCrossPlatformLookAndFeelClassName() ); } catch (Exception e) { }... Default is to use native look and feel 12 6

Step 2: Make the Components JFrame frame = new JFrame( SwingApplication ); SwingApplication app = new SwingApplication(); Component contents = app.createcomponents(); frame.getcontentpane().add(contents, BorderLayout.CENTER); Frames are windows ContentPane is the display area (w/o menu bar) contents added to the frame Layed out as BorderLayout.CENTER 13 Step 3: Install any Listeners frame.addwindowlistener(new WindowAdapter() { public void windowclosing(windowevent e) { System.exit(0); } }); WindowAdapter implements WindowListener Contains default do-nothing methods Notice we ignore the value of e 14 7

Step 4: Make Window Visible } frame.pack(); frame.setvisible(true); pack() sizes window to fit subcomponents setvisible(true) shows the window Not drawn until this is set main(string[] args) exits Swing event thread handles events 15 Layout and Painting Swing places components according to layout manager Don t need to worry about screen size etc. (Not really true) Window painted from back to front Component paints itself before subcomponents Double-buffered so painting looks smooth 16 8

The Event-Dispatching Thread All events are dispatched by a single thread Implies events dispatched in order Also implies next event not processed until current event dispatch returns Need to make event dispatch fast (Re)-painting also done in event-dispatching thread What if another thread needs to modify GUI? Swing library mostly not thread safe 17 Single-Thread Rule Once a Swing component has been realized, all code that might affect or depend on the state of that component should be executed in the event dispatching thread. java.sun.com tutorial A component is realized after setvisible(true) ( == deprecated show()) pack() 18 9

Dealing with Threads Wait a second, what about the example? f.pack(); // f is realized here f.setvisible(true); // so isn t this unsafe? Apparently this usually works, so it s OK (?) A few methods can be used from any thread SwingUtilities.invokeLater(Runnable r) Event-dispatching thread will invoke r (after all pending events dealt with) 19 Making Event Dispatch Fast Standard problem in event or interruptdriven systems Short tasks in response to events are fine Divide long tasks into top half, bottom half Top half is quick; typically, buffers Bottom half runs in separate thread Consumes data from buffer Can use invokelater() if it eventually updates GUI 20 10

UI Hall of Fame or Shame? 21 UI Hall of Shame Application directory dialog (not system) Inconsistent Requires typing a path name No browse option What if you have many directories? Instead, want recognition over recall 22 11

Tips Don t make the user look stupid The goal of all software users is to be more effective 23 UI Hall of Fame or Shame? 24 12

UI Hall of Fame MS Publisher Modified file dialog Recognition based Browsable names Browsable content Preview can be turned off Optional search Design Suggestion: Add entry box for directly typing in name with auto-completion of filenames 25 Tips User interfaces that directly wrap underlying systems are often bad 26 13