L18cs211sp07-6up - Interactive Programs Introduction to...

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

View Full Document Right Arrow Icon
Introduction to GUIs (Graphical User Interfaces) Lecture 18 CS211 – Spring 2007 2 Interactive Programs y “Classic” view of computer programs: transform inputs to outputs, stop y Event-driven programs: interactive, long-running ± Servers interact with clients ± Applications interact with user(s) user user program input events output events input output 3 GUI Motivation y Interacting with a program ± Program-Driven ² Statements execute in sequential, predetermined order ² Typically use keyboard or file I/O, but program determines when that happens ² Usually single-threaded ± Event-Driven ² Program waits for user input to activate certain statements ² Typically uses a GUI (Graphical User Interface) ² Often multi-threaded y Design. ..Which to pick? ± Program called by another program? ± Program used at command line? ± Program interacts often with user? ± Program used in window environment? y How does Java do GUIs? 4 Java Support for Building GUIs y 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 y Our main focus: Swing ± Building blocks of GUIs ² ² User interactions ± Built upon the AWT (Abstract Window Toolkit) ² Java event model 5 Java Foundation Classes y Pluggable Look-and-Feel Support ± Controls look-and-feel for particular windowing environment ± E.g., Java, Windows, Motif, Mac y Accessibility API ± Supports assistive technologies such as screen readers and Braille y Java 2D ± Drawing ± Includes rectangles, lines, circles, images, . .. y Drag-and-drop ± Support for drag and drop between Java application and a native application y Internationalization ± Support for other languages 6 GUI Statics and GUI Dynamics y Statics: what’s 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 y 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 , . ..
Background image of page 1

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

View Full Document Right Arrow Icon
7 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(
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 4

L18cs211sp07-6up - Interactive Programs Introduction to...

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

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