GUIS: Graphical User Interfaces

Slides:



Advertisements
Similar presentations
1 GUIS: Graphical User Interfaces Their mouse had a mean time between failure of … a week … it would jam up irreparably, or... jam up on the table--...
Advertisements

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.
Graphical User Interfaces CS 2110 Spring Ivan Sutherland: “Sketchpad”,
Corresponds with Chapter 12
Fall 2007CS 225 Graphical User Interfaces Event Handling Appendix C.
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.
Chapter 13: Advanced GUIs and Graphics J ava P rogramming: From Problem Analysis to Program Design, From Problem Analysis to Program Design, Second Edition.
CPSC150 JavaLynn Lambert CPSC150 Week 12 InheritanceInterfaces.
CPSC150 Week 12 Graphical User Interfaces Chapter 11.
Contructing GUI’s in Java Implemented in the Swing API Imported into your programs by: import javax.swing.*; Most Swing programs also need the AWT packages.
Graphic User Interfaces Part 1. Typical GUI Screen from Microsoft Word What GUI “components” can you see? –Menus? Buttons? Labels? What else? –Anything.
PROGRAMMING REVIEW Lab 2 EECS 448 Dr Fengjun Li and Meenakshi Mishra.
Java Programming Chapter 10 Graphical User Interfaces.
Chapter 13 Advanced GUIs and Graphics. Chapter Objectives Learn about applets Explore the class Graphics Learn about the class Font Explore the class.
Java Programming: From Problem Analysis to Program Design, 4e Chapter 12 Advanced GUIs and Graphics.
Applets and Frames CS 21a: Introduction to Computing I First Semester,
CSE 219 Computer Science III Graphical User Interface.
Introduction to GUI in Java 1. Graphical User Interface Java is equipped with many powerful,easy to use GUI component such as input and output dialog.
Object Oriented Programming Ders 11: Interfaces Mustafa Emre İlal
עקרונות תכנות מונחה עצמים תרגול 4 - GUI. Outline  Introduction to GUI  Swing  Basic components  Event handling.
Field Trip #19 Animations with Java By Keith Lynn.
 2002 Prentice Hall, Inc. All rights reserved Introduction Graphical User Interface (GUI) –Gives program distinctive “look” and “feel” –Provides.
1 CSC111H Graphical User Interfaces (GUIs) Introduction GUIs in Java Understanding Events A Simple Application The Containment Hierarchy Layout Managers.
– Advanced Programming P ROGRAMMING IN Lecture 21 Introduction to Swing.
1 Outline 1 Introduction 2 Overview of Swing Components 3 JLabel 4 Event Handling 5 TextFields 6 How Event Handling Works 7 JButton 8 JCheckBox and JRadioButton.
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.
CS Lecture 00 Swing overview and introduction Lynda Thomas
Applets and Frames. Copyright 2005, by the authors of these slides, and Ateneo de Manila University. All rights reserved L14: GUI Slide 2 Applets Usually.
CS Fall 2012, Lab 09 Haohan Zhu. Boston University Slideshow Title Goes Here CS Fall 2012, Lab /20/2015 GUI - Graphical User Interface.
Java GUI. Graphical User Interface (GUI) a list a button a text field a label combo box checkbox.
1 12 Apr 2011 GUIS: Graphical User Interfaces Their mouse had a mean time between failure of … a week … it would jam up irreparably, or... jam up on the.
Introduction to Java Chapter 9 - Graphical User Interfaces and Applets1 Chapter 9 Graphical User Interfaces and Applets.
1 GUIS: Graphical User Interfaces Their mouse had a mean time between failure of … a week … it would jam up irreparably, or... jam up on the table--...
Review_6 AWT, Swing, ActionListener, and Graphics.
Basics of GUI Programming Chapter 11 and Chapter 22.
Creating a Window. A basic window in Java is represented by an object of the class Window in the package java.awt.
Ajmer Singh PGT(IP) JAVA IDE Programming - I. Ajmer Singh PGT(IP) GUI (Graphical User Interface) It is an interface that uses a graphic entities along.
Sadegh Aliakbary Sharif University of Technology Fall 2011.
Chapter 10 - Writing Graphical User Interfaces1 Chapter 10 Writing Graphical User Interfaces.
1 Lecture 8: User Interface Components with Swing.
Applets. 9/04/2005 Copyright 2005, by the authors of these slides, and Ateneo de Manila University. All rights reserved L12: Applets Slide 2 Applets Usually.
Introduction to GUI Programming in Java: Frames, Simple Components, and Layouts.
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.
A Quick Java Swing Tutorial
Graphical User Interfaces
2110: GUIS: Graphical User Interfaces
Java GUI.
8 April 2008 GUIS —Graphical User Interfaces
Java Swing.
Provision for GUIs in Java
Lecture 27 Creating Custom GUIs
CS2110 Lecture 14. GUIS-Layout Spring 2016
Ellen Walker Hiram College
Chapter 13: Advanced GUIs and Graphics
GUIS: Graphical User Interfaces
2110: GUIS: Graphical User Interfaces
Introduction to Computing Using Java
2110: GUIS: Graphical User Interfaces
Steps to Creating a GUI Interface
Week 8 Swing NetBeans GUI Builder
Advanced Programming in Java
2110: Announcements Grades for Prelim 1 are now available. You should have received an from Gradescope about accessing them. Regrade requests will.
Introduction to Graphical Interfaces in Java: AWT and Swing
Advanced GUIs and Graphics
13 April 2010 GUIS: Graphical User Interfaces
Graphical User Interface
Presentation transcript:

GUIS: Graphical User Interfaces Their mouse had a mean time between failure of … a week … it would jam up irreparably, or ... jam up on the table-- ... It had a flimsy cord whose wires would break. Steve Jobs: "... Xerox says it can't be built for < $400, I want a $10 mouse that will never fail and can be mass produced, because it's going to be the primary interface of the computer ..." ... Dean Hovey ... came back, "I've got some good and some bad news. Good news: we've got a new project with Apple. Bad news: I told Steve we'd design a mouse for 10 bucks." ... year later ... we … filed … and were granted a patent, on the electro-mechanical-optical mouse of today; ... we ended up ... [making] the mouse as invisible to people as it is today. Steve Sachs interview on first computer with GUI: Apple Lisa (~$10K in 1982). http://library.stanford.edu/mac/primary/interviews/sachs/trans.html

GUI (Graphical User Interface) Provides a friendly interface between user and program Allows event-driven or reactive programming: The program reacts to events such as button clicks, mouse movement, keyboard input Often is multi-threaded: Different threads of execution can be going on simultaneously Two aspects to making a GUI: Placing components (buttons, text, etc.) in it. TODAY Listening/responding to events Next Lecture

GUI (Graphical User Interface) Provides a friendly interface between user and program Allows event-driven or reactive programming: The program reacts to events such as button clicks, mouse movement, keyboard input Often is multi-threaded: Different threads of execution can be going on simultaneously We use Java’s two packages for doing GUIs: AWT (Abstract or Awful Window Toolkit) —first one Swing —a newer one, which builds on AWT as much as possible JavaFX —completely new! Much more functionality, flexibility, but far too complicated to teach in CS2110. We use Swing (AWT makes an appearance occasionally)

Notes on javax.swing vs. java.awt - java.awt is old; javax.swing is new - use swing wherever possible - swing reuses some awt components - e.g. Dimension, LayoutManager, … - swing component names start with J - e.g. JFrame,JButton instead of Frame, Button

GUIs are trees Frame Menu Content File Edit Button “push me” “hello” Text box Close Save Note: can parse trees…

Class JFrame is in package javax.swing JFrame object: associated with a window on your monitor. Generally, a GUI is a JFrame object with various components placed in it Some methods in a JFrame object hide() show() setVisible(boolean) getX() getY() (coordinates of top-left point) getWidth() getHeight() setLocation(int, int) getTitle() setTitle(String) getLocation() setLocation(int, int) Over 100 methods in a JFrame object! Class JFrame is in package javax.swing

Components Component: Something that can be placed in a GUI window. Some useful concrete subclasses: JButton: Clickable button JLabel: Line of text JTextField: Field into which the user can type JTextArea: Many-row field into which user can type JPanel: Used for graphics; to contain other components JCheckBox: Checkable box with a title JComboBox: Menu of items, one of which can be checked JRadioButton: Same functionality as JCheckBox Container: Can contain other components Box: Can contain other components

Component Class Hierarchy Component: Something that can be placed in a GUI window. These are the basic ones used in GUIs: Component Container JComponent JButton JToggleButton JCheckBox JRadioButton JLabel … Note: just like Expr Int Sum Product … Many operations are recursive tree traversals: - paint, pack, show, handle events, …

Layouts Containers have LayoutManagers - control layout of children Examples: - FlowLayout: place children one after the other, wrap - BoxLayout: place everything in one row or column - BorderLayout: split container into 5 children - GridBagLayout, SpringLayout, … Layouts may require extra parameter to add - e.g. f.add(c, BorderLayout.NORTH)).

Custom components It’s easy to make your own components - just extend an existing class (e.g. JPanel) Can override paintComponent(Graphics g) - Graphics object has methods like “drawLine”, …