Lecture 10: Toolkits: Intrinsics, Callbacks, Resources, Widget hierarchies, Geometry management Brad Myers 05-830 Advanced User Interface Software 1© 2013.

Slides:



Advertisements
Similar presentations
Introduction to Java 2 Programming
Advertisements

Java GUI building with the AWT. AWT (Abstract Window Toolkit) Present in all Java implementations Described in (almost) every Java textbook Adequate for.
Tk Widgets This material is best on several sources –Slides by Dr. Ernest J. Friedman-Hill –various Tcl/Tk books.
Graphical User Interfaces
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.
Advanced Swing. Advanced Layout Managers GridBagLayout – Example: Web Browser (Grid Bag Layout)Web Browser (Grid Bag Layout) BoxLayout – Example: Web.
June 1, 2000 Object Oriented Programming in Java (95-707) Advanced Topics 1 Lecture 9 Object Oriented Programming in Java Advanced Topics Abstract Windowing.
Java Swing Toolkit Graphics The key to effectively using graphics in Java is understanding: –the basic components of the graphics library –the patterns.
Understanding SWING Architecture CS 4170 UI Design Hrvoje Benko Oct. 9, 2001.
Flowchart Start Input weight and height
1 Lecture 10: Toolkits: Intrinsics, Callbacks, Resources, Widget hierarchies, Geometry management Brad Myers Advanced User Interface Software.
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.
Advanced Java Class GUI – part 1. Intro to GUI GUI = Graphical User Interface -- “Gooey” Just because it’s “gooey” does not mean you may write messy code.
1 GUI Elements in Java Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
1 CMSC 132: Object-Oriented Programming II Nelson Padua-Perez William Pugh 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.
1 Lecture 3: Overview of UI Software and Tools Brad Myers Advanced User Interface Software.
Lecture 8: Overview of UI Software and Tools Brad Myers Advanced User Interface Software 1© Brad Myers.
Introduction to Java Swing “We are the sultans of swing” – Mark Knopfler.
Java Programming Chapter 10 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.
Java Software Solutions Lewis and Loftus Chapter 10 1 Copyright 1997 by John Lewis and William Loftus. All rights reserved. Graphical User Interfaces --
MSc Workshop - © S. Kamin, U.Reddy Lect 5 – GUI Prog - 1 Lecture 5 – GUI Programming r Inner classes  this and super r Layout r Reading: m.
CIS 068 Welcome to CIS 083 ! Introduction to GUIs: JAVA Swing.
3461A Readings from the Swing Tutorial. 3461A Overview  The follow is the Table of Contents from the trail “Creating a GUI with JFC/Swing” in the “The.
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.
 2002 Prentice Hall, Inc. All rights reserved Introduction Graphical User Interface (GUI) –Gives program distinctive “look” and “feel” –Provides.
Graphic User Interface. Graphic User Interface (GUI) Most of us interact with computers using GUIs. GUIs are visual representations of the actions you.
Graphics and Event-Driven Programming in Java John C. Ramirez Department of Computer Science University of Pittsburgh.
Laying Out Components Interior Design for GUIs. Nov 042 What is Widget Layout? Positioning widgets in their container (typically a JPanel or a JFrame’s.
GoF: Document Editor Example Rebecca Miller-Webster.
Layout Manager Summary
Object Oriented Programming Engr. M. Fahad Khan Lecturer, Software Engineering Department University of Engineering & Technology, Taxila.
1 Lecture 2: Overview of UI Software and Tools Brad Myers Advanced User Interface Software.
Rujchai Ung-arunyawee Department of Computer Engineering Khon Kaen University.
Java Applets: GUI Components, Events, Etc. Ralph Westfall June, 2010.
Computer Science [3] Java Programming II - Laboratory Course Lab 4: Common GUI Event Types and Listener Interfaces Layout Mangers Faculty of Engineering.
University of Limerick1 Software Architecture Java Layout Managers.
Lec.10 (Chapter 8 & 9) GUI Jiang (Jen) ZHENG June 27 th, 2005.
3461 Laying Out Components Interior Design for GUIs.
The Abstract Window Toolkit (AWT) supports Graphical User Interface (GUI) programming. AWT features include: a rich set of user interface components; a.
Introduction to Java Chapter 9 - Graphical User Interfaces and Applets1 Chapter 9 Graphical User Interfaces and Applets.
GUIs Basic Concepts. GUI GUI : Graphical User Interface Window/Frame : a window on the screen Controls/Widgets : GUI components.
Review_6 AWT, Swing, ActionListener, and Graphics.
1 Lecture 5: Interactive Tools: Prototypers (HyperCard, Director, Visual Basic), Interface Builders Brad Myers Advanced User Interface Software.
Java Swing - Lecture 3 Layout Management
Chapter 10 - Writing Graphical User Interfaces1 Chapter 10 Writing Graphical User Interfaces.
1 Lecture 8: User Interface Components with Swing.
User Interface Components. Layout Placement of UI components in a window – Size & Position Each component occupies a rectangular region in the window.
Developing GUIs With the Eclipse Visual Editor, Swing/AWT Edition David Gallardo.
CSC 205 Programming II Lecture 7 AWT – Event Handling & Layout.
May 6, 1998CS102-02Lecture 6-2 Cross-Platform Programming CS Lecture 6-2 Making everyone happy.
CIS 270—Application Development II Chapter 11—GUI Components: Part I.
Introduction to Swing Mr. Crone. What is Swing? a collection of pre-made Java classes used to create a modern graphical user interface.
Brad Myers Advanced User Interface Software, Spring, 2017
University of Central Florida COP 3330 Object Oriented Programming
Ellen Walker Hiram College
Chap 7. Building Java Graphical User Interfaces
Graphical User Interfaces -- Introduction
Containers and Components
GUIS: Graphical User Interfaces
Panels & Layout Managers
Steps to Creating a GUI Interface
GUI Layouts By: Leonard & Saif.
Layout Organization and Management
Brad Myers : Interaction Techniques Spring, 2019
Graphical User Interface
Presentation transcript:

Lecture 10: Toolkits: Intrinsics, Callbacks, Resources, Widget hierarchies, Geometry management Brad Myers Advanced User Interface Software 1© Brad Myers

Widgets as objects Menus, buttons, scrollbars Refresh themselves and handle input, redraw if change In Unix: Motif and Tk each widget is at least one window Since windows already have mechanisms for mouse enter/leave, etc. But high overhead In most other toolkits, widgets are not windows Decorative lines, labels and boxes also are "widgets“ 2© Brad Myers

Intrinsics How the widgets are implemented Motif -- "fake" object system out of C (same in Andrew) Tk -- Tcl language, and descendents Amulet -- Prototype-instance object system, constraints, Opal graphics model, Interactors input model, command objects Java (for swing): graphics2d & awt input events 3© Brad Myers

“Resources” Starting from original Macintosh as “resource fork” – for language independence (& better memory management) Every parameter of widgets in Motif Passed as a parameter to the create routine, set afterwards, or read from a configuration file Called "options" by Tk Each resource has a default value defined by the class In an X file = appl.widget1.resource: value appl.widget1.widget2.resource: value *.resource: value © Brad Myers4

Callbacks In Motif, associate C procedures with widgets Many different callbacks for the same widget create, start, abort, finish, destroy,... Registered (set) at widget creation time, invoked at run time Are "resources" There are also "actions" which are internal to the widget and called by events. In VB, “event handlers” Button: click, focus-in/out, change, etc. In tk, associate tcl script with "events" in widgets or the widget action if it has one In Amulet, invoke Command Objects on "interactors" or widget finish, and call-back is the DO method. 5© Brad Myers

Widget Hierarchies Inheritance to give the right methods to widgets Functions down the parent or class hierarchy Java swing hierarchy: Thousands of interfaces, classes, subclasses, etc. Separate hierarchies for internal look-and-feel classes Visible when debugging © Brad Myers6

Geometry Management Widgets don't set their own location. Widgets put into special group objects called "geometry managers" that perform the layout by setting the component's positions and size Each widget negotiates with parent for more room when resize 7© Brad Myers

History: TeX layout model Typesetting system designed and mostly written by Donald Knuth starting in 1977 Boxes (of type) connected by “glue” \vspace also between characters, etc. Can control the “stretchiness” of the glue 8© Brad Myers

History: Interviews layout model “Interviews” – one of the first C++ toolkits Linton, M.A., Vlissides, J.M., and Calder, P.R., “Composing user interfaces with InterViews.” IEEE Computer, Feb, (2): pp Adopted the TeX boxes and glue metaphor hbox tiles its components horizontally hglue vbox tiles them vertically Vglue Controls have a “natural” size Different glues and controls have different stretchiness 9© Brad Myers

Motif Geometry Management Motif RowColumn - add widgets and it lays them out Treats all children the same, so not for ScrollBars (picture) Form - generic constrained layout Put extra resources on the children widgets "For details, see the Motif Reference Manual, because the complete behavior of Form is quite complicated." Each edge can be constrained at a position or offset from an edge of the Form at an offset from an edge of another widget percent of the way across the Form (edge, not center) a percent calculated based on the initial position If wrong, widgets are on top of each other 10© Brad Myers

TK Geometry Management All widgets must be in a geometry manager, or else not displayed Any widget with any geometry manager Layout depends on widget specified sizes programmer specifications, size of geometry manager itself Widgets must adjust themselves to the size given Geometry manager requests size recursively 11© Brad Myers

TK Geometry, Cont. Placer - specific location for each widget Each widget treated independently Place "anchor" in absolute coords or as a % of way across then say which part of object is at the anchor n, ne, e, se,... center Packer - "constraint based" specify position of each widget in available space side left, right, top, bottom fill x, -fill y stretch widget to fill available space Text Canvas - mix graphics and widgets 12© Brad Myers

Amulet geometry management Group can have the Am_LAYOUT slot set with a constraint that depends on other slots Sets positions of parts by side effect Default layout routines: Horizontal and Vertical layout, for lists or tables. Rest done by arbitrary constraints 13© Brad Myers

Java Widget Layout “Using Layout Managers” “Using Layout Managers” BorderLayout – layout around the edges, center gets extra space BoxLayout – vertical or horizontal columns CardLayout – overlapping JPanels FlowLayout – fills row, then goes to next row GridBagLayout – “one of the most flexible — and complex — layout managers the Java platform provides…. uses a grid of rows and columns, allowing specified components to span multiple rows or columns.” GridLayout -- components in a grid of cells. Resizes children to fill cell GroupLayout – new, designed for use by IBs SpringLayout -- also new for IBs, constraints for layouts 14© Brad Myers

“Struts and Springs” layout For stretchy or rigid constraints Graphical interface layouts NeXTStep (1989), MacOS & Galaxy (~1992) 15© Brad Myers