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.

Slides:



Advertisements
Similar presentations
Generics and the ArrayList Class
Advertisements

1 (c) elsaddik CSI 1102 Introduction to Software Design Prof. Dr.-Ing. Abdulmotaleb El Saddik University of Ottawa (SITE.
Slides prepared by Rose Williams, Binghamton University Chapter 14 Generics and the ArrayList Class.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Java Software Solutions Foundations of Program Design Sixth Edition by Lewis.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Java Software Solutions Foundations of Program Design Sixth Edition by Lewis.
Lecture 15 Graphical User Interfaces (GUI’s). Objectives Provide a general set of concepts for GUI’s Layout manager GUI components GUI Design Guidelines.
Wecksten, Mattias Arrays Based on templates from Lewis & Loftus.
Using ArrayList. Lecture Objectives To understand the foundations behind the ArrayList class Explore some of the methods of the ArrayList class.
Chapter Day 14. © 2007 Pearson Addison-Wesley. All rights reserved5-2 Agenda Day 14 Problem set 3 posted  10 problems from chapters 5 & 6  Due in 11.
1 Arrays  Arrays are objects that help us organize large amounts of information  Chapter 8 focuses on: array declaration and use passing arrays and array.
Slides prepared by Rose Williams, Binghamton University Chapter 14 Generics and the ArrayList Class.
Chapter 14 Generics and the ArrayList Class Copyright © 2010 Pearson Addison-Wesley. All rights reserved.
Fall 2007CS 2251 Lists and the Collection Interface Chapter 4.
Aalborg Media Lab 28-Jun-15 Software Design Lecture 8 “Arrays”
Chapter 7 Arrays. © 2004 Pearson Addison-Wesley. All rights reserved7-2 Arrays Arrays are objects that help us organize large amounts of information Chapter.
1 More on Arrays Arrays of objects Command line arguments The ArrayList class Javadoc Review Lecture 8 notes and L&L 7.1 – 7.2 Reading for this lecture:
ITEC220 GUI Lecture – Part 1 References  Java Software Solutions,” by Lewis & Loftus  Chapter 3  Chapter 4  Chapter 5  Chapter 6  Java Foundations-Introduction.
Chapter 13: Advanced GUIs and Graphics J ava P rogramming: From Problem Analysis to Program Design, From Problem Analysis to Program Design, Second Edition.
Chapter 6: Arrays Java Software Solutions Third Edition
Chapter Day 12. © 2007 Pearson Addison-Wesley. All rights reserved5-2 Agenda Day 12 Problem set corrected  1 A, 2 B’s and 1 D Starting Late and not turning.
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.
ELC 312 Day 16. © 2004 Pearson Addison-Wesley. All rights reserved Agenda Questions? Capstone Proposals Due Problem set 3 Corrected  Poor performance.
Chapter 13 Advanced GUIs and Graphics. Chapter Objectives Learn about applets Explore the class Graphics Learn about the class Font Explore the class.
Java Software Solutions Lewis and Loftus Chapter 7 1 Copyright 1997 by John Lewis and William Loftus. All rights reserved. Graphics -- Introduction The.
Java Software Solutions Lewis and Loftus Chapter 10 1 Copyright 1997 by John Lewis and William Loftus. All rights reserved. Graphical User Interfaces --
Java Programming: From Problem Analysis to Program Design, 4e Chapter 12 Advanced GUIs and Graphics.
Chapter 7 Arrays. © 2004 Pearson Addison-Wesley. All rights reserved7-2 Arrays Arrays are objects that help us organize large amounts of information Chapter.
Chapter 11 Arrays Continued
Chapter 6: Arrays Presentation slides for Java Software Solutions for AP* Computer Science by John Lewis, William Loftus, and Cara Cocking Java Software.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Java Software Solutions Foundations of Program Design Sixth Edition by Lewis.
MT311 Java Application Development and Programming Languages Li Tak Sing ( 李德成 )
© 2011 Pearson Education, publishing as Addison-Wesley Chapter 6: Arrays Presentation slides for Java Software Solutions for AP* Computer Science 3rd Edition.
Canvas and Graphics CS 21a. 9/26/2005 Copyright 2005, by the authors of these slides, and Ateneo de Manila University. All rights reserved L17: Canvas.
Chapter 14 Generics and the ArrayList Class Slides prepared by Rose Williams, Binghamton University Copyright © 2008 Pearson Addison-Wesley. All rights.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Java Software Solutions Foundations of Program Design Sixth Edition by Lewis.
Chapter 7 Arrays 5 TH EDITION Lewis & Loftus java Software Solutions Foundations of Program Design © 2007 Pearson Addison-Wesley. All rights reserved.
1 Arrays An array is an ordered list of values An array of size N is indexed from zero to N-1 scores.
Java Software Solutions Foundations of Program Design Sixth Edition by Lewis & Loftus Chapter 7: Arrays.
Chapter overview This chapter focuses on Array declaration and use Bounds checking and capacity Arrays storing object references Variable length parameter.
Aug 9, CMSC 202 ArrayList. Aug 9, What’s an Array List ArrayList is  a class in the standard Java libraries that can hold any type of object.
© 2004 Pearson Addison-Wesley. All rights reserved October 15, 2007 Searching ComS 207: Programming I (in Java) Iowa State University, FALL 2007 Instructor:
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 6 – Graphical User Interfaces Java Foundations: Introduction to Programming.
Java Programming, Second Edition Chapter Thirteen Understanding Swing Components.
CSE 1201 Object Oriented Programming ArrayList 1.
1 Sorting b Sorting is the process of arranging a list of items into a particular order b There must be some value on which the order is based b There.
Java Software Solutions Lewis and Loftus Chapter 6 1 Copyright 1997 by John Lewis and William Loftus. All rights reserved. Objects for Organizing Data.
© 2011 Pearson Education, publishing as Addison-Wesley Chapter 6: Arrays Presentation slides for Java Software Solutions for AP* Computer Science 3rd Edition.
Java Programming Fifth Edition Chapter 13 Introduction to Swing Components.
Chapter 6: Arrays Java Software Solutions
Chapter 9: Graphical User Interfaces
A First Look at GUI Applications Radio Buttons and Check Boxes
CHAPTER 7 & 8 REVIEW QUESTIONS
Miscellaneous Topics #6: Polygons GUI Components and Event Handlers
Chap 7. Building Java Graphical User Interfaces
Chapter 13: Advanced GUIs and Graphics
Graphical User Interfaces -- Introduction
Chapter 12 Collections.
The ArrayList Class An ArrayList is a complex data structure that allows you to add or remove objects from a list and it changes size automatically. The.
Object Oriented Programming in java
Chapter 12 Collections.
Chapter 6: Arrays and Vectors
Advanced GUIs and Graphics
Arrays.
TA: Nouf Al-Harbi NoufNaief.net :::
Presentation transcript:

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 with permission. All rights reserved.

2 Introduction  The portion of chapter 6 that we read in this class focuses on the use of arrays in GUI’s & graphics:  In particular: the ArrayList class polygons and polylines more button components

3 The ArrayList Class  The ArrayList class is part of the java.util package  Like an array, it can store a list of values and reference them with an index  Unlike an array, an ArrayList object grows and shrinks as needed  Items can be inserted or removed with a single method invocation  It stores references to the Object class, which allows it to store any kind of object  See Beatles.java (page 357) Beatles.java

4 ArrayList Efficiency  The ArrayList class is implemented using an array  The code of the ArrayList class automatically expands the array's capacity to accommodate additional elements  The array is manipulated so that indexes remain continuous as elements are added or removed  If elements are added to and removed from the end of the list, this processing is fairly efficient  If elements are inserted and removed from the middle of the list, the elements are constantly being shifted around

5 Polygons and Polylines  Arrays often are helpful in graphics processing  Polygons and polylines are shapes that can be defined by values stored in arrays  A polyline is similar to a polygon except that its endpoints do not meet, and it cannot be filled  See Rocket.java (page 360) Rocket.java

6 The Rocket Program

7 The Polygon Class  The Polygon class, defined in the java.awt package can be used to define and draw a polygon  Two versions of the overloaded drawPolygon and fillPolygon methods each take a single Polygon object as a parameter  A Polygon object encapsulates the coordinates of the polygon

8 Check Boxes  A check box is a button that can be toggled on or off  A check box is represented by the JCheckBox class  A change of state generates an item event  The ItemListener interface corresponds to item events  The itemStateChanged method of the listener responds when a check box changes state

9 The StyleOptions Program  A frame is a container that can be used to create stand- alone GUI applications  A frame is represented by the JFrame class  A Font object represents by the font's: family name (such as Times or Courier) style (bold, italic, or both) font size  See StyleOptions.java (page 364)StyleOptions.java  See StyleGUI.java (page 365)StyleGUI.java

10 The StyleOptions Program

11 Radio Buttons  A set of radio buttons represents a set of mutually exclusive options This set is a “ButtonGroup”.  When a radio button from a group is selected, the other button currently "on" in the group is toggled off  A radio button generates an action event  See QuoteOptions.java (page 368) QuoteOptions.java  See QuoteGUI.java (page 369) QuoteGUI.java

12 The QuoteOptions Program

13 Summary  The portion of Chapter 6 that we have studied has focused on: the ArrayList class polygons and polylines more button components