Chapter 8: Animation Copyright 2002, Matthew Evett. These slides are based on slides copyrighted by John Lewis and William Loftus, 2002, and used with.

Slides:



Advertisements
Similar presentations
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 2-1 Outline Graphics Applets Drawing Shapes Components and Containers Images.
Advertisements

© 2004 Pearson Addison-Wesley. All rights reserved10-1 Chapter 10 : Exceptions Intermediate Java Programming Summer 2007.
ITEC220 GUI Lecture – Part 2 References  Java Software Solutions,” by Lewis & Loftus  Chapter 7  Chapter 8  Chapter 9  Java Foundations-Introduction.
File I/O and Exceptions File I/O Exceptions Throwing Exceptions Try statement and catch / finally clauses Checked and unchecked exceptions Throws clause.
Chapter 8 Inheritance 5 TH EDITION Lewis & Loftus java Software Solutions Foundations of Program Design © 2007 Pearson Addison-Wesley. All rights reserved.
(C) 2010 Pearson Education, Inc. All rights reserved. Java™ How to Program, 8/e.
Visual Basic 2010 How to Program Reference: Instructor: Maysoon Bin Duwais slides Visual Basic 2010 how to program by Deitel © by Pearson Education,
Chapter 5: Keyboard I/O & Simple GUI’s Copyright 2002, Matthew Evett. These slides are based on slides copyrighted by John Lewis and William Loftus, 2002,
Lecture 15 Graphical User Interfaces (GUI’s). Objectives Provide a general set of concepts for GUI’s Layout manager GUI components GUI Design Guidelines.
Chapter 8: Exceptions and I/O Streams Copyright 2002, Matthew Evett. These slides are based on slides copyrighted by John Lewis and William Loftus, 2002,
Chapter Day 23. © 2007 Pearson Addison-Wesley. All rights reserved Agenda Day 23 Problem set 4 Due Problem set 5 Posted (Last one)  Due Dec 8 Capstones.
Chapter Day 6. © 2007 Pearson Addison-Wesley. All rights reserved2-2 Agenda Day 5 Questions from last Class?? Problem set 1 DUE Problem set 2 posted 
Chapter 6: Arrays & More GUI Copyright 2002, Matthew Evett. These slides are based on slides copyrighted by John Lewis and William Loftus, 2002, and used.
Chapter Day 10. © 2007 Pearson Addison-Wesley. All rights reserved4-2 Agenda Day 10 Questions from last Class?? Problem set 2 posted  10 programs from.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Java Software Solutions Foundations of Program Design Sixth Edition by Lewis.
Chapter 9 Polymorphism 5 TH EDITION Lewis & Loftus java Software Solutions Foundations of Program Design © 2007 Pearson Addison-Wesley. All rights reserved.
Chapter Day 21. © 2007 Pearson Addison-Wesley. All rights reserved7-2 Agenda Day 20 Problem set 4 Posted  10 problems from chapters 7 & 8  Due Nov 21.
ITEC220 GUI Lecture – Part 1 References  Java Software Solutions,” by Lewis & Loftus  Chapter 3  Chapter 4  Chapter 5  Chapter 6  Java Foundations-Introduction.
Chapter Day 9. © 2007 Pearson Addison-Wesley. All rights reserved4-2 Agenda Day 8 Questions from last Class?? Problem set 2 posted  10 programs from.
Chapter Day 19. © 2007 Pearson Addison-Wesley. All rights reserved7-2 Agenda Day 19 Problem set 3 Corrected  1 A, 2 B’s and 1 D Problem set 4 Posted.
Chapter 8 Inheritance. © 2004 Pearson Addison-Wesley. All rights reserved8-2 Inheritance Inheritance is a fundamental object-oriented design technique.
ELC 312 Day 16. © 2004 Pearson Addison-Wesley. All rights reserved Agenda Questions? Capstone Proposals Due Problem set 3 Corrected  Poor performance.
Chapter 8: Exceptions and I/O Streams Copyright 2002, Matthew Evett. These slides are based on slides copyrighted by John Lewis and William Loftus, 2002,
© 2004 Pearson Addison-Wesley. All rights reserved8-1 Chapter 8 : Inheritance Intermediate Java Programming Summer 2007.
10-1 Exceptions An exception is an object that describes an unusual or erroneous situation Exceptions are thrown by a program, and may be caught and handled.
Chapter 8: Writing Graphical User Interfaces
Java Software Solutions Lewis and Loftus Chapter 10 1 Copyright 1997 by John Lewis and William Loftus. All rights reserved. Graphical User Interfaces --
Chapter 5: Enhancing Classes
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Graphical User Interfaces Revisited Material from Chapters
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.
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Event Driven Programming, The.
Java Programming: Guided Learning with Early Objects
Ch 3-4: GUI Basics Java Software Solutions Foundations of Program Design Sixth Edition by Lewis & Loftus Coming up: GUI Components.
1 Graphical User Interfaces AWT and Swing packages Frames and Panels Components Nested Panels Images Reading for this Lecture: L&L, 3.9 – 3.11.
MSc Workshop - © S. Kamin, U. ReddyLect 3 - GUI -1 Lecture 3 - Graphical User Interfaces r GUI toolkits in Java API r JFrame r GUI components.
Timer class and inner classes. Processing timer events Timer is part of javax.swing helps manage activity over time Use it to set up a timer to generate.
1 Chapter Ten Using Controls. 2 Objectives Learn about Controls How to create a Form containing Labels How to set a Label’s Font How to add Color to a.
© Copyright 2012 by Pearson Education, Inc. All Rights Reserved. Chapter 9 GUI Programming Using Tkinter 1.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 15 Creating User.
CHAPTER:07 JAVA IDE PROGRAMMING-II Prepared By Prepared By : VINAY ALEXANDER ( विनय अलेक्सजेंड़र ) PGT(CS),KV JHAGRAKHAND.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 6 – Graphical User Interfaces Java Foundations: Introduction to Programming.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 4: Events Programming with Alice and Java First Edition by John Lewis.
Creating User Interfaces Chapter 13 CSCI CSCI 1302 – Creating User Interfaces2 Outline Introduction Common Features of Swing GUI Components Buttons.
Creating User Interfaces Event-Driven Programming.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Tutorial 2 – Welcome Application Introduction to Graphical.
Chapter 10 Exceptions 5 TH EDITION Lewis & Loftus java Software Solutions Foundations of Program Design © 2007 Pearson Addison-Wesley. All rights reserved.
Oct 091 Example Program DemoInputValidation1.java DemoInputValidation2.java.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Java Software Solutions Foundations of Program Design Sixth Edition by Lewis.
Polygons and Polylines © 2004 Pearson Addison-Wesley. All rights reserved 7-1 Arrays can be helpful in graphics processing For example, they can be used.
CSC 1051 – Data Structures and Algorithms I Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University Course website:
1 Lesson 6 Introducing JavaScript HTML and JavaScript BASICS, 4 th Edition.
Graphic User Interface. Introduction to Graphics The last few sections of each chapter of the textbook focus on graphics and graphical user interfaces.
Chapter 5: Enhancing Classes Presentation slides for Java Software Solutions Foundations of Program Design Second Edition by John Lewis and William Loftus.
Chapter 9: Graphical User Interfaces
10 Exceptions Software Solutions Lewis & Loftus java 5TH EDITION
Chapter 10 Exceptions.
Chapter 10 Exceptions.
ITEC220 GUI Lecture – Part 2 References
TA: Nouf Al-Harbi NoufNaief.net :::
Presentation transcript:

Chapter 8: Animation Copyright 2002, Matthew Evett. These slides are based on slides copyrighted by John Lewis and William Loftus, 2002, and used with permission. All rights reserved.

File Choosers  A GUI-based program sometimes involve the use of external files  A file chooser is a specialized dialog box created using the JFileChooser class  A file chooser allows the user to browse a disk or other storage device to select a file  A text area is similar to a text field, but can contain multiple lines  See DisplayFile.java (page 482) DisplayFile.java

The DisplayFile Program

Color Choosers  A color chooser is a component that allows a user to specify a color  It is similar to a file chooser in that it displays a special purpose dialog box  It is created using the JColorChooser class  A color can be selected using swatches or RGB values  See DisplayColor.java (page 484) DisplayColor.java

The DisplayColor Program

Image Icons  An image icon object represents an image  ImageIcon objects use either JPEG or GIF images  They can be used in several situations, such as being displayed in a label  A JLabel can contain a String, and ImageIcon, or both  The orientation of the label's text and image can be set explicitly  See LabelDemo.java (page 487) LabelDemo.java  See LabelPanel.java (page 488) LabelPanel.java

The LabelDemo Program

Key Events  A key event is generated when a keyboard key is pressed  Constants in the KeyEvent class can be used to determine which key was pressed  The KeyListener interface contains three methods, representing three events: key pressed – a key is pressed key released – a key is released key typed – called when a pressed key produces a key character  See Direction.java (page 490) Direction.java  See DirectionPanel.java (page 491) DirectionPanel.java

The Direction Program

Animations  An animation is a series of images that gives the appearance of movement  To create the illusion of movement, we use a timer to change the scene after an appropriate delay  The Timer class of the javax.swing package represents a component, even though it has no visual representation  A Timer object generates an action event at specified intervals

Animations  The start and stop methods of the Timer class start and stop the timer  The delay can be set using the Timer constructor or using the setDelay method  See Rebound.java (page 496) Rebound.java  See ReboundPanel.java (page 497) ReboundPanel.java

The Rebound Program

Summary  Chapter 8 has focused on: the try-catch statement exception propagation creating and throwing exceptions types of I/O streams Keyboard class processing reading and writing text files object serialization and deserialization more GUI components key events animations