CS 280 Data Structures Professor John Peterson. Quiz 4 Recap Consider the following array: {2, 6, 7, 3, 4, 1, 5, 9}. Draw this in tree form and then show.

Slides:



Advertisements
Similar presentations
OLD BUSINESS : Lets talk about the next exam Project proposals – Functional Definitions Go over homework – NEW BUSINESS: Chapter 4 today GUIs Assignment.
Advertisements

2D Graphics Drawing Things. Graphics In your GUI, you might want to draw graphics E.g. draw lines, circles, shapes, draw strings etc The Graphics class.
Web Design & Development Lecture 19. Java Graphics 2.
Drawing in a frame – Java GUI
Mouse Listeners We continue our examination of GUIs by looking at how to interact with the mouse –Just as Java creates Events when the user interacts with.
Graphics You draw on a Graphics object The Graphics object cannot directly be created by your code, instead one is generated when the method paintComponent.
Unit 3 Graphical User Interface (GUI) Dr. Magdi AMER.
Problem Solving 6 GUIs and Event Handling ICS-201 Introduction to Computing II Semester 071.
1 Drawing C Sc 335 Object-Oriented Programming and Design Rick Mercer.
Chapter 4 (Horstmann’s Book) Interface Types and Polymorphism: Graphics, Timer, Animation Hwajung Lee.
GUI and Swing, part 2 The illustrated edition. Scroll bars As we have previously seen, a JTextArea has a fixed size, but the amount of text that can be.
Event Driven Programming and GUIs Part 3 CS221 – 4/15/09.
Chapter 6 Graphical User Interface (GUI) and Object-Oriented Design (OOD)
CS 280 Data Structures Professor John Peterson. Project Questions? /CIS280/f07/project5http://wiki.western.edu/mcis/index.php.
Event Handling Events and Listeners Timers and Animation.
CS 280 Data Structures Professor John Peterson. Test #1 We’ll do a test next week on Wednesday. It will take the entire period. You can have 1 page of.
CS 280 Data Structures Professor John Peterson. Invariants Back to Invariants! Recall the insertion sort invariant – how can we turn this into debugging.
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.
CS 280 Data Structures Professor John Peterson. Goals Understand “Programming in the small” Java programming Know what’s under the hood in complex libraries.
CS 112 GUI 06 May 2008 Bilkent. Java GUI API Containers: ◦ contain other GUI components. E.g, Window, Panel, Applet, Frame Dialog. Components: ◦ Buttons,
CS 280 Data Structures Professor John Peterson. Homework / Project Note the homework isn’t due till tomorrow. Plus it’s not too hard. The project IS due.
Animation To animate our programs, that is, to have real time interactions where objects move on the screen, we want to call repaint( ) every few milliseconds.
Programming Task: Task 1 Controlled Assessment Practice.
Chapter 6: Graphical User Interface (GUI) and Object-Oriented Design (OOD) J ava P rogramming: Program Design Including Data Structures Program Design.
Java Programming Chapter 10 Graphical User Interfaces.
Applets Java API.
JLabel, JTextField, JButton and JOptionPane
Draw Shapes Introduction to simple graphics. What is a Component? A class that resides in the java.awt package Examples include: –Button, java.awt.Button.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. C H A P T E R T E N Event-Driven Programming.
Using the Netbeans GUI Builder. The Netbeans IDE provides a utility called the GUI Builder that assists you with creating Windows applications. The Netbeans.
Java Programming: From Problem Analysis to Program Design, Second Edition1  Learn about basic GUI components.  Explore how the GUI components JFrame,
CIS 068 Welcome to CIS 083 ! Introduction to GUIs: JAVA Swing.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Outline 20.1 Test-Driving the Screen Saver Application.
Lesson 27: Introduction to the Java GUI. // helloworldbutton.java import java.awt.*; import javax.swing.*; class HelloButton{ public static void main.
Lab 6: event & input intro User Interface Lab: GUI Lab Oct. 2 nd, 2013.
CS 112 Department of Computer Science George Mason University CS 112 Department of Computer Science George Mason University Writing Graphic Applications.
MT311 Java Application Development and Programming Languages Li Tak Sing ( 李德成 )
GUIs in Java Swing, Events CS2110, SW Development Methods Readings: MSD, Chapter 12 Lab Exercise.
Field Trip #19 Animations with Java By Keith Lynn.
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.
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.
Swing GUI Components You can create graphics components to place on your applet using classes available in the Swing package ( javax.swing ) Class names.
Chapter 5: Ball Worlds Features 2 classes, constant data fields, constructors, extension through inheritance, graphics.
Concurrent Programming and Threads Threads Blocking a User Interface.
ITEC 109 Lecture 27 GUI. GUIs Review Sounds –Arrays hold sample values –Creating a keyboard –Sound effects Homework 3 –The big two –Due after break –Lab.
Creating Windows. How can we use Java to create programs that use windows (GUI applications)? How can we use Java to create programs that use windows.
CS324e - Elements of Graphics and Visualization Java GUIs - Event Handling.
Lec.10 (Chapter 8 & 9) GUI Jiang (Jen) ZHENG June 27 th, 2005.
1 GUIs, Layout, Drawing Rick Mercer. 2 Event-Driven Programming with Graphical user Interfaces  Most applications have graphical user interfaces (GUIs)
Java Programming: From Problem Analysis to Program Design, 3e Chapter 6 Graphical User Interface (GUI) and Object-Oriented Design (OOD)
Java Programming: From Problem Analysis to Program Design, Second Edition1 Lecture 5 Objectives  Learn about basic GUI components.  Explore how the GUI.
Review_6 AWT, Swing, ActionListener, and Graphics.
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.
Java Swing One of the most important features of Java is its ability to draw graphics.
JAVA: An Introduction to Problem Solving & Programming, 6 th Ed. By Walter Savitch ISBN © 2012 Pearson Education, Inc., Upper Saddle River,
CS 5JA Introduction to Java Graphics One of the powerful things about Java is that there is.
1 Drawing C Sc 335 Object-Oriented Programming and Design Rick Mercer.
Java With NetBeans First Project. Java Are language for this semester is Java The Development Environment is Netbeans.
Swing GUI Components So far, we have written GUI applications which can ‘ draw ’. These applications are simple, yet typical of all Java GUI applications.
Chapter 6 Graphical User Interface (GUI) and Object-Oriented Design (OOD)
5-1 GUIs and Events Rick Mercer. 5-2 Event-Driven Programming with Graphical user Interfaces  Most applications have graphical user interfaces to respond.
Java Programming Fifth Edition Chapter 13 Introduction to Swing Components.
Prepared by: Dr. Abdallah Mohamed, AOU-KW Unit7: Event-driven programming 1.
Event Loops and GUI Intro2CS – weeks
Java Programming: From Problem Analysis to Program Design,
GUI AND GRAPHICS.
Ellen Walker Hiram College
Extend Text Editor to Draw shapes
Week 8 Swing NetBeans GUI Builder
Presentation transcript:

CS 280 Data Structures Professor John Peterson

Quiz 4 Recap Consider the following array: {2, 6, 7, 3, 4, 1, 5, 9}. Draw this in tree form and then show the array after each exchange in stage 1 of heapsort. For stage 2, show the array NOT in tree form but as an array at the end of each iteration of the loop after the swap and the call to heapify Suppose we sort an array of 1,000,000 items. What is the maximum number of calls to heapify generated by heapify(0, s, )? You can use round numbers – off by 1 is good enough.

New Timetable Projects due Monday Homework due Friday

This Week We have a big “todo” this week – understanding how to create animations in Java. Note – we’re not using the ACM library! No homework this week so you can concentrate on coding. I will go through the theory here and then let you work on the project in Netbeans.

How to do Animation Need a JFrame at the top level (this is something you can select in NetBeans when you create a file) The JFrame has two views: code and design. You can switch between these. Code shows the actual code with protected areas, design shows what happens when the code runs.

How to do Animation Top level variables have to go in the JFrame There’s a special place for initialization if you want to do something at startup You need to set up a timer to wake the program up to display the next frame of animation The timer calls a “step()” method to change the animation state

How to do Animation Objects which change during the animation need a custom paint method. You need to subclass the Java objects to add this You need to use custom creation code in Netbeans to make this work Objects like buttons can talk to the program through events Drag and drop to create objects

How to do Animation Widgets to know: JPanel: a place to draw pictures JButton: a push button that sends “ActionPerformed” when you push it JLabel: a place to put text Graphics: this is a class used to draw pictures – it’s part of the repaint process

How to do Animation Drawing: Use setColor to choose a paint color Use fillRectangle to create rectangles (that’s all we need in this class) (0,0) is at the top left, coordinates are in pixels Labels: setText is needed to change the text Set the font at design time

Your Program import all sorts of library stuff Main class (extends JFrame) Program level vars, including timer Classes to add graphics to GUI objects Constructor Place initializers here (timer too) Step() method to change animation Event handlers and helpers

Into the Wiki Start your Netbeans now Todays stuff doesn’t need the previous project. /CIS280/f07/project5http://wiki.western.edu/mcis/index.php /CIS280/f07/project5