L10cs2110fa08 - Introduction to Graphical User Interfaces...

Info iconThis preview shows pages 1–9. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Introduction to Graphical User Interfaces (GUIs) Lecture 10 CS2110 Fall 2008 Announcements A3 is up, due Friday, Oct 10 Prelim 1 scheduled for Oct 16 if you have a conflict, let us know now 2 3 Interactive Programs Classic view of computer programs: transform inputs to outputs, stop Event-driven programs: interactive, long-running Servers interact with clients Applications interact with user(s) user user program input events output events input output 4 GUI Motivation Interacting with a program Program-Driven = Proactive Statements execute in sequential, predetermined order Typically use keyboard or file I/O, but program determines when that happens Usually single-threaded Event-Driven = Reactive Program waits for user input to activate certain statements Typically uses a GUI (Graphical User Interface) Often multi-threaded Design...Which to pick? Program called by another program? Program used at command line? Program interacts often with user? Program used in window environment? How does Java do GUIs? 5 Java Support for Building GUIs Java Foundation Classes Classes for building GUIs Major components awt and swing Pluggable look-and-feel support Accessibility API Java 2D API Drag-and-drop Support Internationalization Our main focus: Swing Building blocks of GUIs Windows & components User interactions Built upon the AWT (Abstract Window Toolkit) Java event model 6 Java Foundation Classes Pluggable Look-and-Feel Support Controls look-and-feel for particular windowing environment E.g., Java, Windows, Mac Accessibility API Supports assistive technologies such as screen readers and Braille Java 2D Drawing Includes rectangles, lines, circles, images, ... Drag-and-drop Support for drag and drop between Java application and a native application Internationalization Support for other languages 7 GUI Statics and GUI Dynamics Statics: whats drawn on the screen Components buttons, labels, lists, sliders, menus, ... Containers: components that contain other components frames, panels, dialog boxes, ... Layout managers: control placement and sizing of components Dynamics: user interactions Events button-press, mouse-click, key- press, ... Listeners: an object that responds to an event Helper classes Graphics , Color , Font , FontMetrics , Dimension , ... 8 Creating a Window import javax.swing.*; public class Basic1 { public static void main(String args) { //create the window JFrame f = new JFrame( "Basic Test!" ); //quit Java after closing the window f.setDefaultCloseOperation(JFrame. EXIT_ON_CLOSE ); f.setSize(200, 200); //set size in pixels f.setVisible( true ); //show the window } } 8 Creating a Window import javax.swing.*; public class Basic1 { public static void main(String args) { //create the window...
View Full Document

This note was uploaded on 02/01/2010 for the course CS 2110 at Cornell University (Engineering School).

Page1 / 31

L10cs2110fa08 - Introduction to Graphical User Interfaces...

This preview shows document pages 1 - 9. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online