YEAH session #6. 6 March 2014, 5:30p-6:30p Miles Seiver

Size: px
Start display at page:

Download "YEAH session #6. 6 March 2014, 5:30p-6:30p Miles Seiver"

Transcription

1 YEAH session #6 6 March 2014, 5:30p-6:30p Miles Seiver

2 Review session schedule Topic Date Time Location assignment 6 today! now! here! assignment 7 Sun 16 Mar 7p - 8p Hewlett 200

3 Interactors

4

5 JSlider slide = new JSlider(min, max, initial); JButton button = new JButton( [button text] ); JTextField field = new JTextField( [field text] );

6 JSlider slide = new JSlider(min, max, initial); JButton button = new JButton( [button text] ); JTextField field = new JTextField( [field text] ); add(interactor, location);

7

8 addactionlisteners();

9 addactionlisteners(); public void actionperformed(actionevent e) { }

10 addactionlisteners(); public void actionperformed(actionevent e) { if (e.getsource() == someinteractorivar) {!!...! } }

11 addactionlisteners(); public void actionperformed(actionevent e) { if (e.getsource() == someinteractorivar) {!!...! requires instance variables } }

12 addactionlisteners(); public void actionperformed(actionevent e) { if (e.getsource() == someinteractorivar) {!!...! requires instance variables } if (e.getactioncommand().equals( [text in button] )) {!!...! } }

13 addactionlisteners(); public void actionperformed(actionevent e) { if (e.getsource() == someinteractorivar) {!!...! requires instance variables } } if (e.getactioncommand().equals( [text in button] )) {!!...! } only works for buttons unless you use someinteractor.setactioncommand( [action command] )

14 the assignment

15 NameSurfer due Wed, 12 3:15pm

16 demo

17 New Java tools you will use!

18 New Java tools you will use! HashMap

19 New Java tools you will use! HashMap Array

20 New Java tools you will use! HashMap Array Interactors

21

22

23

24

25

26 ..

27 ..

28 ..

29 ..

30 ..

31 ..

32 NameSurferDatabase

33 NameSurferDatabase

34

35

36

37 name is case-insensitive

38 name is case-insensitive

39 NameSurferDatabase.java

40 NameSurferDatabase.java rank 0 means the name did not appear in the top 1000 names for that year

41 NameSurferDatabase.java String line = rd.readline(); rank 0 means the name did not appear in the top 1000 names for that year

42 NameSurferDatabase.java String line = rd.readline(); NameSurferEntry entry = new NameSurferEntry(line); rank 0 means the name did not appear in the top 1000 names for that year

43 NameSurferDatabase.java String line = rd.readline(); NameSurferEntry entry = new NameSurferEntry(line); //Store this NameSurferEntry so it can be retrieved rank 0 means the name did not appear in the top 1000 names for that year

44 NameSurferEntry

45 NameSurferEntry

46

47

48

49

50

51 NameSurferEntry.java String getname()! int getrank(int decade)! String tostring()

52 NameSurferEntry.java String getname()! int getrank(int decade)! String tostring()

53 NameSurferEntry.java String getname()! int getrank(int decade)! String tostring()

54 NameSurferEntry.java Sam String getname()! int getrank(int decade)! String tostring()

55 NameSurferEntry.java Sam rankdata name Sam String getname()! int getrank(int decade)! String tostring()

56 NameSurferGraph

57 NameSurferGraph

58

59

60

61

62

63 entries Sam NameSurferEntry

64 entries Sam NameSurferEntry Samantha NameSurferEntry

65 entries Sam NameSurferEntry ( ) Samantha NameSurferEntry ( )

66 entries from NameSurferConstants Sam NameSurferEntry ( ) Samantha NameSurferEntry ( )

67 (0,0) entries from NameSurferConstants Sam NameSurferEntry ( ) Samantha NameSurferEntry ( )

68 (0,0) getwidth() entries from NameSurferConstants Sam NameSurferEntry ( ) Samantha NameSurferEntry ( )

69 (0,0) getwidth() getheight() entries from NameSurferConstants Sam NameSurferEntry ( ) Samantha NameSurferEntry ( )

70 (0,0) getwidth() getheight() entries from NameSurferConstants Sam NameSurferEntry ( ) Samantha NameSurferEntry ( )

71 (0,0) getwidth() getheight() entries from NameSurferConstants Sam NameSurferEntry ( ) Samantha NameSurferEntry ( )

72 (0,0) getwidth() getheight() entries from NameSurferConstants Sam NameSurferEntry ( ) Samantha NameSurferEntry ( )

73 (0,0) getwidth() getheight() entries from NameSurferConstants Sam NameSurferEntry ( ) Samantha NameSurferEntry ( )

74 (0,0) getwidth() getheight() entries from NameSurferConstants Sam NameSurferEntry ( ) Samantha NameSurferEntry ( )

75 (0,0) getwidth() getheight() entries from NameSurferConstants Sam NameSurferEntry ( ) Samantha NameSurferEntry ( )

76 (0,0) getwidth() getheight() entries from NameSurferConstants Sam NameSurferEntry ( ) Samantha NameSurferEntry ( )

77 (0,0) getwidth() getheight() entries from NameSurferConstants Sam NameSurferEntry ( ) Samantha NameSurferEntry ( )

78 (0,0) getwidth() getheight() entries from NameSurferConstants Sam NameSurferEntry ( ) Samantha NameSurferEntry ( )

79 (0,0) getwidth() getheight() entries from NameSurferConstants Sam NameSurferEntry ( ) Samantha NameSurferEntry ( )

80 (0,0) getwidth() getheight() entries from NameSurferConstants Sam NameSurferEntry ( ) Samantha NameSurferEntry ( )

81 (0,0) getwidth() getheight() entries from NameSurferConstants Sam NameSurferEntry ( ) Samantha NameSurferEntry ( )

82 (0,0) getwidth() getheight() entries from NameSurferConstants Sam NameSurferEntry ( ) Samantha NameSurferEntry ( )

83 (0,0) getwidth() getheight() entries from NameSurferConstants Sam NameSurferEntry ( ) Samantha NameSurferEntry ( )

84 (0,0) getwidth() getheight() entries from NameSurferConstants Sam NameSurferEntry ( ) Samantha NameSurferEntry ( )

85 entries from NameSurferConstants Sam NameSurferEntry ( ) Samantha NameSurferEntry ( )

86 NameSurferConstants

87

88 NameSurfer

89 NameSurfer

90

91 To add the graph to the screen

92 To add the graph to the screen init()

93

94

95

96

97 ..

98 ..

99 ..

100 ..

101 ..

102 ..

103 Tricky parts

104 Tricky parts null pointer exceptions

105 Tricky parts null pointer exceptions OutOfBoundsException

106 Tricky parts null pointer exceptions OutOfBoundsException off-by-one drawing

107 Tricky parts null pointer exceptions OutOfBoundsException off-by-one drawing resizing using update()

YEAH Session #6. November 13, 2014, 6-7 PM Nick Troccoli

YEAH Session #6. November 13, 2014, 6-7 PM Nick Troccoli YEAH Session #6 November 13, 2014, 6-7 PM Nick Troccoli YEAH Hours Schedule Topic Date Time Loca-on Assignment 6 Today! Now! Here! Assignment 7 11/21 (Fri) 4:15-5:05PM HewleP 200 Final Exam 12/10 (Wed)

More information

Assignment 6 YEAH Hours. Ben Barnett and Avery Wang

Assignment 6 YEAH Hours. Ben Barnett and Avery Wang Assignment 6 YEAH Hours Ben Barnett and Avery Wang 2 Overview 1. Review relevant material. 2. Discuss each milestone. 3. Q&A Classes Define your very own variable type! 4 What custom variables have you

More information

CS 106A, Lecture 24 Interactors and NameSurfer

CS 106A, Lecture 24 Interactors and NameSurfer CS 106A, Lecture 24 Interactors and NameSurfer suggested reading: Java Ch. 10.5-10.6 This document is copyright (C) Stanford Computer Science and Marty Stepp, licensed under Creative Commons Attribution

More information

Classes. How can we manage large programs?

Classes. How can we manage large programs? Classes How can we manage large programs? GRect: keeps track of x, y, width, height, color, visibility ArrayList: Maintains a list of elements (under the hood, it manages an array for you) String: stores

More information

CS 106A, Lecture 23 Interactors and GCanvas

CS 106A, Lecture 23 Interactors and GCanvas CS 106A, Lecture 23 Interactors and GCanvas suggested reading: Java Ch. 10.5-10.6 This document is copyright (C) Stanford Computer Science and Marty Stepp, licensed under Creative Commons Attribution 2.5

More information

Mehran Sahami Handout #39 CS 106A November 14, 2007 Assignment #6 NameSurfer Due: 3:15pm on Wednesday, November 28th

Mehran Sahami Handout #39 CS 106A November 14, 2007 Assignment #6 NameSurfer Due: 3:15pm on Wednesday, November 28th Mehran Sahami Handout #39 CS 106A November 14, 2007 Assignment #6 NameSurfer Due: 3:15pm on Wednesday, November 28th The NameSurfer assignment was created by Nick Parlante and further revised by Patrick

More information

Interactors. Brahm Capoor.

Interactors. Brahm Capoor. Interactors Brahm Capoor brahm@stanfordedu Learning goals for today To learn how to use interactors in our programs Learning goals for today To learn how to use interactors in our programs To go under

More information

Assignment 6: NameSurfer

Assignment 6: NameSurfer CS106A Winter 2011-2012 Handout #27 February 29, 2011 Assignment 6: NameSurfer Assignment by Nick Parlante, with revisions by Patrick Young and Eric Roberts At this point, you now possess all the tools

More information

Assignment #6 NameSurfer

Assignment #6 NameSurfer Math 121: Introduction to Computing Handout #?? Assignment #6 NameSurfer Due: Monday, December 11 The NameSurfer assignment was created by Nick Parlante, who also wrote parts of this handout. This assignment

More information

Solution to Section #7

Solution to Section #7 Chris Piech Section #7 CS 106A Feburary 28, 2018 Solution to Section #7 Portions of this handout by Eric Roberts and Nick Troccoli 1. Word Cloud /** * File: WordCloud.java * -------------------- * This

More information

EVENTS, EVENT SOURCES AND LISTENERS

EVENTS, EVENT SOURCES AND LISTENERS Java Programming EVENT HANDLING Arash Habibi Lashkari Ph.D. Candidate of UTM University Kuala Lumpur, Malaysia All Rights Reserved 2010, www.ahlashkari.com EVENTS, EVENT SOURCES AND LISTENERS Important

More information

CS106A Final Exam Review Session. Saturday Dec. 10, 2016 Nick Troccoli

CS106A Final Exam Review Session. Saturday Dec. 10, 2016 Nick Troccoli CS106A Final Exam Review Session Saturday Dec. 10, 2016 Nick Troccoli 1 Today s Topic List Primitives, Objects, and Heap/Stack Graphics + Animation Event-Driven Programs Strings + chars Classes + Interfaces

More information

Objects Revisited. An object is a combination of. State persistent information, and Behavior the ability to operate on that state.

Objects Revisited. An object is a combination of. State persistent information, and Behavior the ability to operate on that state. Classes Some Quick Thoughts Objects Revisited An object is a combination of State persistent information, and Behavior the ability to operate on that state. GRect state: Position Size Color Is filled?

More information

CS 106A Winter 2017 Final Solutions

CS 106A Winter 2017 Final Solutions CS 106A Winter 2017 Final Solutions 1a. public void run() { for(int i = 100; i >= 0; i -= 5) { println(i); 1b. public void printkeys(hashmap map) { for(string key : map.ketset()) { println(key);

More information

CS/ENGRD 2110 FALL Lecture 2: Objects and classes in Java

CS/ENGRD 2110 FALL Lecture 2: Objects and classes in Java 1 CS/ENGRD 2110 FALL 2017 Lecture 2: Objects and classes in Java http://courses.cs.cornell.edu/cs2110 CMS VideoNote.com, PPT slides, DrJava 2 CMS. Visit course webpage, click Links, then CMS for 2110.

More information

CS/ENGRD 2110 SPRING Lecture 2: Objects and classes in Java

CS/ENGRD 2110 SPRING Lecture 2: Objects and classes in Java 1 CS/ENGRD 2110 SPRING 2014 Lecture 2: Objects and classes in Java http://courses.cs.cornell.edu/cs2110 Java OO (Object Orientation) 2 Python and Matlab have objects and classes. Strong-typing nature of

More information

CS/ENGRD 2110 SPRING Lecture 2: Objects and classes in Java

CS/ENGRD 2110 SPRING Lecture 2: Objects and classes in Java 1 CS/ENGRD 2110 SPRING 2018 Lecture 2: Objects and classes in Java http://courses.cs.cornell.edu/cs2110 Homework HW1 2 The answers you handed in at the end of lecture 1 showed mass confusion! Perhaps 80%

More information

Answers to Additional Practice Final Problems

Answers to Additional Practice Final Problems Handout #36A CS 106A Aug 11, 2011 Answers to Additional Practice Final Problems Problem Interactors public class InteractorsSample extends GraphicsProgram{ private GLine fwdslash; private GLine backslash;

More information

CS/ENGRD 2110 SPRING Lecture 2: Objects and classes in Java

CS/ENGRD 2110 SPRING Lecture 2: Objects and classes in Java 1 CS/ENGRD 2110 SPRING 2017 Lecture 2: Objects and classes in Java http://courses.cs.cornell.edu/cs2110 CMS VideoNote.com, PPT slides, DrJava, Book 2 CMS available. Visit course webpage, click Links, then

More information

AP CS Unit 11: Graphics and Events

AP CS Unit 11: Graphics and Events AP CS Unit 11: Graphics and Events This packet shows how to create programs with a graphical interface in a way that is consistent with the approach used in the Elevens program. Copy the following two

More information

CS/ENGRD 2110 FALL Lecture 2: Objects and classes in Java

CS/ENGRD 2110 FALL Lecture 2: Objects and classes in Java 1 CS/ENGRD 2110 FALL 2018 Lecture 2: Objects and classes in Java http://courses.cs.cornell.edu/cs2110 Homework HW1 2 The answers you handed in at the end of lecture 1 showed mass confusion! Perhaps 80%

More information

Solutions to Section #7

Solutions to Section #7 Colin Kincaid Section #7 CS 106A August 10, 2018 Solutions to Section #7 Portions of this handout by Mehran Sahami, Eric Roberts, Marty Stepp, Nick Troccoli, and Julia Daniel 1. Colored Window import acm.program.*;

More information

CS 170 Java Programming 1. Week 9: Learning about Loops

CS 170 Java Programming 1. Week 9: Learning about Loops CS 170 Java Programming 1 Week 9: Learning about Loops What s the Plan? Topic 1: A Little Review ACM GUI Apps, Buttons, Text and Events Topic 2: Learning about Loops Different kinds of loops Using loops

More information

Quick Overview. Strings Data Structures. Classes. Array Grid ArrayList HashMap (with File Reading)

Quick Overview. Strings Data Structures. Classes. Array Grid ArrayList HashMap (with File Reading) CS106A Review Quick Overview Strings Data Structures Array Grid ArrayList HashMap (with File Reading) Classes String Tips Access characters of a String by index, starting with 0 Strings are immutable:

More information

Assignment #7 FacePamphlet Due: 1:30pm on Friday, December 7th Note: No late days (free or otherwise) may be used on Assignment #7

Assignment #7 FacePamphlet Due: 1:30pm on Friday, December 7th Note: No late days (free or otherwise) may be used on Assignment #7 Mehran Sahami Handout #45 CS 106A November 28, 2018 Assignment #7 FacePamphlet Due: 1:30pm on Friday, December 7th Note: No late days (free or otherwise) may be used on Assignment #7 This assignment may

More information

UI Software Organization

UI Software Organization UI Software Organization The user interface From previous class: Generally want to think of the UI as only one component of the system Deals with the user Separate from the functional core (AKA, the app

More information

What Is an Event? Some event handler. ActionEvent. actionperformed(actionevent e) { }

What Is an Event? Some event handler. ActionEvent. actionperformed(actionevent e) { } CBOP3203 What Is an Event? Events Objects that describe what happened Event Sources The generator of an event Event Handlers A method that receives an event object, deciphers it, and processes the user

More information

Section Handout #7: Interactors and Classes

Section Handout #7: Interactors and Classes Chris Piech Section Handout 7 CS 106A February 27, 2017 Section Handout #7: Interactors and Classes 1. Using Interactors Portions of this handout by Eric Roberts and Nick Troccoli The purpose of this problem

More information

CSE 8B Programming Assignments Spring Programming: You will have 5 files all should be located in a dir. named PA3:

CSE 8B Programming Assignments Spring Programming: You will have 5 files all should be located in a dir. named PA3: PROGRAMMING ASSIGNMENT 3: Read Savitch: Chapter 7 Programming: You will have 5 files all should be located in a dir. named PA3: ShapeP3.java PointP3.java CircleP3.java RectangleP3.java TriangleP3.java

More information

Breakout YEAH hours. Brahm Capoor & Jared Wolens

Breakout YEAH hours. Brahm Capoor & Jared Wolens Breakout YEAH hours Brahm Capoor & Jared Wolens Road Map YEAH hour schedule Deadline: Due Wednesday, February 8th Lecture Review Using the debugger Assignment Overview Q&A! YEAH hours this quarter Assignment

More information

CSC 160 LAB 8-1 DIGITAL PICTURE FRAME. 1. Introduction

CSC 160 LAB 8-1 DIGITAL PICTURE FRAME. 1. Introduction CSC 160 LAB 8-1 DIGITAL PICTURE FRAME PROFESSOR GODFREY MUGANDA DEPARTMENT OF COMPUTER SCIENCE 1. Introduction Download and unzip the images folder from the course website. The folder contains 28 images

More information

TWO-DIMENSIONAL FIGURES

TWO-DIMENSIONAL FIGURES TWO-DIMENSIONAL FIGURES Two-dimensional (D) figures can be rendered by a graphics context. Here are the Graphics methods for drawing draw common figures: java.awt.graphics Methods to Draw Lines, Rectangles

More information

Practice Final Examination #1

Practice Final Examination #1 Eric Roberts Handout #58 CS 106A May 25, 2012 Practice Final Examination #1 Review session: Wednesday, June 6, 7:30 9:30 P.M. (Hewlett 200) Scheduled finals: Friday, June 8, 8:30 11:30 A.M. (Dinkelspiel

More information

COL106: Data Structures and Algorithms. Ragesh Jaiswal, IIT Delhi

COL106: Data Structures and Algorithms. Ragesh Jaiswal, IIT Delhi Stack and Queue How do we implement a Queue using Array? : A collection of nodes with linear ordering defined on them. Each node holds an element and points to the next node in the order. The first node

More information

Chapter 6: Inheritance

Chapter 6: Inheritance Chapter 6: Inheritance EECS 1030 moodle.yorku.ca State of an object final int WIDTH = 3; final int HEIGTH = 4; final int WEIGHT = 80; GoldenRectangle rectangle = new GoldenRectangle(WIDTH, HEIGHT, WEIGHT);

More information

Programming Languages and Techniques (CIS120)

Programming Languages and Techniques (CIS120) Programming Languages and Techniques (CIS120) Lecture 24 March 18, 2016 The Java ASM What is the value of ans at the end of this program? Counter[] a = { new Counter(), new Counter() ; Counter[] b = {

More information

Administrivia. CSSS Movie Night: Zombieland & Iron Man Date: Thurs., Mar 11 Time: 6 10 pm Location: DMP 310 Free pop & popcorn for every attendee!

Administrivia. CSSS Movie Night: Zombieland & Iron Man Date: Thurs., Mar 11 Time: 6 10 pm Location: DMP 310 Free pop & popcorn for every attendee! Department of Computer Science Undergraduate Events Events this week Drop-In Resume and Cover Letter Editing (20 min. appointments) Date: Thurs., March 11 Time: 11:30 am 2:30 pm Location: Rm 255, ICICS/CS

More information

Day before tests of Java Final test. IDM institution of Bandarawela. Project for department of education

Day before tests of Java Final test. IDM institution of Bandarawela. Project for department of education Day before tests of Java Final test. IDM institution of Bandarawela Project for department of education import javax.swing.*; import java.awt.*; import java.awt.event.*; public class Doenets extends JApplet

More information

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written. QUEEN'S UNIVERSITY SCHOOL OF COMPUTING HAND IN Answers Are Recorded on Question Paper CMPE212, FALL TERM, 2012 FINAL EXAMINATION 18 December 2012, 2pm Instructor: Alan McLeod If the instructor is unavailable

More information

Solution register itself

Solution register itself Observer Pattern Context: One object (the Subject) is the source of events. Other objects (Observers) want to know when an event occurs. Or: several objects should be immediately updated when the state

More information

CSE115 / CSE503 Introduction to Computer Science I. Dr. Carl Alphonce 343 Davis Hall Office hours:

CSE115 / CSE503 Introduction to Computer Science I. Dr. Carl Alphonce 343 Davis Hall Office hours: CSE115 / CSE503 Introduction to Computer Science I Dr. Carl Alphonce 343 Davis Hall alphonce@buffalo.edu Office hours: Thursday 12:00 PM 2:00 PM Friday 8:30 AM 10:30 AM OR request appointment via e-mail

More information

CSSE 490 Model-Based Software Engineering

CSSE 490 Model-Based Software Engineering CSSE 490 Model-Based Software Engineering Project Milestone 1 This first Milestone develops the first iteration of the system, FacePamphlet, that we want to develop. Ultimately we will use this as the

More information

CMP-326 Exam 2 Spring 2018 Solutions Question 1. Version 1. Version 2

CMP-326 Exam 2 Spring 2018 Solutions Question 1. Version 1. Version 2 Question 1 30 30 60 60 90 20 20 40 40 60 Question 2 a. b. public Song(String title, String artist, int length, String composer) { this.title = title; this.artist = artist; this.length = length; this.composer

More information

Practice Final Examination #1

Practice Final Examination #1 Eric Roberts Handout #63 CS 106A March 5, 2010 Practice Final Examination #1 Review session: Sunday, March 14, 7:00 9:00P.M. (Hewlett 201) Scheduled finals: Monday, March 15, 12:15 3:15P.M. (Hewlett 200)

More information

We Want You for future InfProgOO!

We Want You for future InfProgOO! Five-Minute Review 1. What are the three data structures realized in the Java Collections Framework? 2. What is hashing used for, how does it work? 3. What do iteractors do? 4. What are interactive programs?

More information

To gain experience using GUI components and listeners.

To gain experience using GUI components and listeners. Lab 5 Handout 7 CSCI 134: Fall, 2017 TextPlay Objective To gain experience using GUI components and listeners. Note 1: You may work with a partner on this lab. If you do, turn in only one lab with both

More information

DEMYSTIFYING PROGRAMMING: CHAPTER SIX METHODS (TOC DETAILED) CHAPTER SIX: METHODS 1

DEMYSTIFYING PROGRAMMING: CHAPTER SIX METHODS (TOC DETAILED) CHAPTER SIX: METHODS 1 DEMYSTIFYING PROGRAMMING: CHAPTER SIX METHODS (TOC DETAILED) CHAPTER SIX: METHODS 1 Objectives 1 6.1 Methods 1 void or return 1 Parameters 1 Invocation 1 Pass by value 1 6.2 GUI 2 JButton 2 6.3 Patterns

More information

Agenda. Container and Component

Agenda. Container and Component Agenda Types of GUI classes/objects Step-by-step guide to create a graphic user interface Step-by-step guide to event-handling PS5 Problem 1 PS5 Problem 2 Container and Component There are two types of

More information

Introduction. Introduction

Introduction. Introduction Introduction Many Java application use a graphical user interface or GUI (pronounced gooey ). A GUI is a graphical window or windows that provide interaction with the user. GUI s accept input from: the

More information

YEAH Hours. January , 7-8 PM Jared Wolens

YEAH Hours. January , 7-8 PM Jared Wolens YEAH Hours January 23 2017, 7-8 PM Jared Wolens YEAH Hours? Held after each assignment is released Future dates to be scheduled soon Review + Assignment Tips Plan for today: lecture review, assignment

More information

Example: Building a Java GUI

Example: Building a Java GUI Steven Zeil October 25, 2013 Contents 1 Develop the Model 2 2 Develop the layout of those elements 3 3 Add listeners to the elements 9 4 Implement custom drawing 12 1 The StringArt Program To illustrate

More information

CoSc Lab # 5 (The Controller)

CoSc Lab # 5 (The Controller) CoSc 10403 Lab # 5 (The Controller) Due Date: Part I, Experiment classtime, Thursday, Oct 25 th, 2018. Part II, Program - by midnight, Thursday, Oct 25 th, 2018. Part I MUST be typed and submitted to your

More information

Example 3-1. Password Validation

Example 3-1. Password Validation Java Swing Controls 3-33 Example 3-1 Password Validation Start a new empty project in JCreator. Name the project PasswordProject. Add a blank Java file named Password. The idea of this project is to ask

More information

Example: Building a Java GUI

Example: Building a Java GUI Steven Zeil October 25, 2013 Contents 1 Develop the Model 3 2 Develop the layout of those elements 4 3 Add listeners to the elements 12 4 Implement custom drawing 15 1 The StringArt Program To illustrate

More information

Expressions, Statements, and Control Structures

Expressions, Statements, and Control Structures Expressions, Statements, and Control Structures Announcements Assignment 2 out, due next Wednesday, February 1. Explore the Java concepts we've covered and will be covering. Unleash your creative potential!

More information

Section Handout #7: Interactors and Classes

Section Handout #7: Interactors and Classes Chris Piech Section #7 CS 106A February 26, 2018 Section Handout #7: Interactors and Classes Portions of this handout by Eric Roberts and Nick Troccoli Overview: these problems will give you practice with

More information

CS 134 Programming Exercise 7:

CS 134 Programming Exercise 7: CS 134 Programming Exercise 7: Scribbler Objective: To gain more experience using recursion and recursive data structures. This week, you will be implementing a program we call Scribbler. You have seen

More information

Java Programming Lecture 6

Java Programming Lecture 6 Java Programming Lecture 6 Alice E. Fischer Feb 15, 2013 Java Programming - L6... 1/32 Dialog Boxes Class Derivation The First Swing Programs: Snow and Moving The Second Swing Program: Smile Swing Components

More information

Chapter 17 Creating User Interfaces

Chapter 17 Creating User Interfaces Chapter 17 Creating User Interfaces 1 Motivations A graphical user interface (GUI) makes a system user-friendly and easy to use. Creating a GUI requires creativity and knowledge of how GUI components work.

More information

CS 61B Data Structures and Programming Methodology. July 2, 2008 David Sun

CS 61B Data Structures and Programming Methodology. July 2, 2008 David Sun CS 61B Data Structures and Programming Methodology July 2, 2008 David Sun Announcements Project 1 spec and code is available on the course website. Due July 15 th. Start early! Midterm I is next Wed in

More information

Introduction to Graphical User Interfaces (GUIs) Lecture 10 CS2110 Fall 2008

Introduction to Graphical User Interfaces (GUIs) Lecture 10 CS2110 Fall 2008 Introduction to Graphical User Interfaces (GUIs) Lecture 10 CS2110 Fall 2008 Announcements A3 is up, due Friday, Oct 10 Prelim 1 scheduled for Oct 16 if you have a conflict, let us know now 2 Interactive

More information

We are on the GUI fast track path

We are on the GUI fast track path We are on the GUI fast track path Chapter 13: Exception Handling Skip for now Chapter 14: Abstract Classes and Interfaces Sections 1 9: ActionListener interface Chapter 15: Graphics Skip for now Chapter

More information

Lecture 3: Java Graphics & Events

Lecture 3: Java Graphics & Events Lecture 3: Java Graphics & Events CS 62 Fall 2017 Kim Bruce & Alexandra Papoutsaki Text Input Scanner class Constructor: myscanner = new Scanner(System.in); can use file instead of System.in new Scanner(new

More information

Window Interfaces Using Swing Objects

Window Interfaces Using Swing Objects Chapter 12 Window Interfaces Using Swing Objects Event-Driven Programming and GUIs Swing Basics and a Simple Demo Program Layout Managers Buttons and Action Listeners Container Classes Text I/O for GUIs

More information

Bringing Life to Swing Desktop Applications

Bringing Life to Swing Desktop Applications Bringing Life to Swing Desktop Applications Alexander Potochkin Sun Microsystems Kirill Grouchnikov Amdocs Inc. TS-3414 2007 JavaOne SM Conference Session TS-3414 Presentation Goal Learn advanced painting

More information

2IS45 Programming

2IS45 Programming Course Website Assignment Goals 2IS45 Programming http://www.win.tue.nl/~wsinswan/programmeren_2is45/ Rectangles Learn to use existing Abstract Data Types based on their contract (class Rectangle in Rectangle.

More information

Topic 9: Swing. Swing is a BIG library Goal: cover basics give you concepts & tools for learning more

Topic 9: Swing. Swing is a BIG library Goal: cover basics give you concepts & tools for learning more Swing = Java's GUI library Topic 9: Swing Swing is a BIG library Goal: cover basics give you concepts & tools for learning more Assignment 5: Will be an open-ended Swing project. "Programming Contest"

More information

Topic 9: Swing. Why are we studying Swing? GUIs Up to now: line-by-line programs: computer displays text user types text. Outline. 1. Useful & fun!

Topic 9: Swing. Why are we studying Swing? GUIs Up to now: line-by-line programs: computer displays text user types text. Outline. 1. Useful & fun! Swing = Java's GUI library Topic 9: Swing Swing is a BIG library Goal: cover basics give you concepts & tools for learning more Why are we studying Swing? 1. Useful & fun! 2. Good application of OOP techniques

More information

Graphical User Interface (GUI)

Graphical User Interface (GUI) Graphical User Interface (GUI) An example of Inheritance and Sub-Typing 1 Java GUI Portability Problem Java loves the idea that your code produces the same results on any machine The underlying hardware

More information

CMP 326 Midterm Fall 2015

CMP 326 Midterm Fall 2015 CMP 326 Midterm Fall 2015 Name: 1) (30 points; 5 points each) Write the output of each piece of code. If the code gives an error, write any output that would happen before the error, and then write ERROR.

More information

CS 2334: Programming Structures and Abstractions Exam 2 November 4, Please wait to open this exam booklet until you are told to do so.

CS 2334: Programming Structures and Abstractions Exam 2 November 4, Please wait to open this exam booklet until you are told to do so. General instructions: CS 2334: Programming Structures and Abstractions Exam 2 November 4, 2015 Please wait to open this exam booklet until you are told to do so. This examination booklet has 13 pages.

More information

Commands. Written commands can be reused, cataloged, etc. Sometimes they also contain "undo" commands, too.

Commands. Written commands can be reused, cataloged, etc. Sometimes they also contain undo commands, too. Commands A command is something you want someone else to perform. Instead of directly issuing a command, we can write it down and give it to someone to perform. Written commands can be reused, cataloged,

More information

Constants are named in ALL_CAPS, using upper case letters and underscores in their names.

Constants are named in ALL_CAPS, using upper case letters and underscores in their names. Naming conventions in Java The method signature Invoking methods All class names are capitalized Variable names and method names start with a lower case letter, but every word in the name after the first

More information

Outline. Topic 9: Swing. GUIs Up to now: line-by-line programs: computer displays text user types text AWT. A. Basics

Outline. Topic 9: Swing. GUIs Up to now: line-by-line programs: computer displays text user types text AWT. A. Basics Topic 9: Swing Outline Swing = Java's GUI library Swing is a BIG library Goal: cover basics give you concepts & tools for learning more Assignment 7: Expand moving shapes from Assignment 4 into game. "Programming

More information

COURSE DESCRIPTION. John Lewis and William Loftus; Java: Software Solutions; Addison Wesley

COURSE DESCRIPTION. John Lewis and William Loftus; Java: Software Solutions; Addison Wesley COURSE DESCRIPTION Dept., Number Semester hours IS 323 Course Title 4 Course Coordinator Object Oriented Programming Catherine Dwyer and John Molluzzo Catalog Description (2004-2006) Continued development

More information

CS 106X, Lecture 16 More Linked Lists

CS 106X, Lecture 16 More Linked Lists CS 106X, Lecture 16 More Linked Lists reading: Programming Abstractions in C++, Chapters 11-12, 14.1-14.2 This document is copyright (C) Stanford Computer Science and Nick Troccoli, licensed under Creative

More information

Course Status Networking GUI Wrap-up. CS Java. Introduction to Java. Andy Mroczkowski

Course Status Networking GUI Wrap-up. CS Java. Introduction to Java. Andy Mroczkowski CS 190 - Java Introduction to Java Andy Mroczkowski uamroczk@cs.drexel.edu Department of Computer Science Drexel University March 10, 2008 / Lecture 8 Outline Course Status Course Information & Schedule

More information

Solutions to Practice Final Exam

Solutions to Practice Final Exam Chris Piech Handout #48 CS106A March 18, 2017 Solutions to Practice Final Exam Problem 1: Short answer (15 points) Portions of this handout by Eric Roberts Answer for 1a: When an object is passed into

More information

Course Supervisor: Dr. Humera Tariq Hands on Lab Sessions: Ms. Sanya Yousuf

Course Supervisor: Dr. Humera Tariq Hands on Lab Sessions: Ms. Sanya Yousuf Course Supervisor: Dr. Humera Tariq Hands on Lab Sessions: Ms. Sanya Yousuf UML to represent and using single object Practice writing code for class Practice tostring( ) function Practice writing your

More information

Administrivia. IBM Info Session Date: Wed,, Jan 13 Time: 5:30 7 pm Location: Wesbrook 100

Administrivia. IBM Info Session Date: Wed,, Jan 13 Time: 5:30 7 pm Location: Wesbrook 100 Department of Computer Science Undergraduate Events Events this week Drop-In Resume Edition Date: Mon. Jan 11 Time: 11 am 2 pm Location: Rm 255, ICICS/CS Industry Panel Speakers: Managers from IBM, Microsoft,

More information

Class Meeting #8 8 Puzzle. COS 226 Based in part ok slides by Jérémie Lumbroso and Kevin Wayne

Class Meeting #8 8 Puzzle. COS 226 Based in part ok slides by Jérémie Lumbroso and Kevin Wayne Class Meeting #8 8 Puzzle COS 226 Based in part ok slides by Jérémie Lumbroso and Kevin Wayne LEVEL-ORDER TRAVERSAL Level-order traversal of a binary tree. Process root. Process children of root, from

More information

Software and Programming 1

Software and Programming 1 Software and Programming 1 Week 9 Lab - Use of Classes and Inheritance 8th March 2018 SP1-Lab9-2018.ppt Tobi Brodie (Tobi@dcs.bbk.ac.uk) 1 Lab 9: Objectives Exercise 1 Student & StudentTest classes 1.

More information

The class Object. Lecture CS1122 Summer 2008

The class Object.  Lecture CS1122 Summer 2008 The class Object http://www.javaworld.com/javaworld/jw-01-1999/jw-01-object.html Lecture 10 -- CS1122 Summer 2008 Review Object is at the top of every hierarchy. Every class in Java has an IS-A relationship

More information

H212 Introduction to Software Systems Honors

H212 Introduction to Software Systems Honors Introduction to Software Systems Honors Lecture #19: November 4, 2015 1/14 Third Exam The third, Checkpoint Exam, will be on: Wednesday, November 11, 2:30 to 3:45 pm You will have 3 questions, out of 9,

More information

CSCI 136 Written Exam #2 Fundamentals of Computer Science II Spring 2015

CSCI 136 Written Exam #2 Fundamentals of Computer Science II Spring 2015 CSCI 136 Written Exam #2 Fundamentals of Computer Science II Spring 2015 Name: This exam consists of 6 problems on the following 6 pages. You may use your double- sided hand- written 8 ½ x 11 note sheet

More information

The JFrame Class Frame Windows GRAPHICAL USER INTERFACES. Five steps to displaying a frame: 1) Construct an object of the JFrame class

The JFrame Class Frame Windows GRAPHICAL USER INTERFACES. Five steps to displaying a frame: 1) Construct an object of the JFrame class CHAPTER GRAPHICAL USER INTERFACES 10 Slides by Donald W. Smith TechNeTrain.com Final Draft 10/30/11 10.1 Frame Windows Java provides classes to create graphical applications that can run on any major graphical

More information

+! Today. Lecture 3: ArrayList & Standard Java Graphics 1/26/14! n Reading. n Objectives. n Reminders. n Standard Java Graphics (on course webpage)

+! Today. Lecture 3: ArrayList & Standard Java Graphics 1/26/14! n Reading. n Objectives. n Reminders. n Standard Java Graphics (on course webpage) +! Lecture 3: ArrayList & Standard Java Graphics +! Today n Reading n Standard Java Graphics (on course webpage) n Objectives n Review for this week s lab and homework assignment n Miscellanea (Random,

More information

Interfaces & Polymorphism part 2: Collections, Comparators, and More fun with Java graphics

Interfaces & Polymorphism part 2: Collections, Comparators, and More fun with Java graphics Interfaces & Polymorphism part 2: Collections, Comparators, and More fun with Java graphics 1 Collections (from the Java tutorial)* A collection (sometimes called a container) is simply an object that

More information

Lecture 4: The class hierarchy; static components

Lecture 4: The class hierarchy; static components 1 CS/ENGRD 2110 FALL2017 Lecture 4: The class hierarchy; static components http://cs.cornell.edu/courses/cs2110 Announcements 2 A1 Due Thursday A2 Out Today Where am I? Big ideas so far. 3 Java variables

More information

Java Applets This is not a Java course! (You re supposed to know about Java.)

Java Applets This is not a Java course! (You re supposed to know about Java.) IT 3203 Introduction to Web Development Java and the Web IA and the Enterprise November 26 28 Study Abroad Spend July in Madrid Informational meeting: Wednesday, November 28 3:00 pm in Room J-308 http://spsumadrid08.blogspot.com/

More information

Abstract Class. Lecture 21. Based on Slides of Dr. Norazah Yusof

Abstract Class. Lecture 21. Based on Slides of Dr. Norazah Yusof Abstract Class Lecture 21 Based on Slides of Dr. Norazah Yusof 1 Abstract Class Abstract class is a class with one or more abstract methods. The abstract method Method signature without implementation

More information

Java 9 (was bisher geschah) JFS 2018 Java 10 et cetera

Java 9 (was bisher geschah) JFS 2018 Java 10 et cetera 3 Java 9 (was bisher geschah) 10 Java 10 12 Set nameset = Collections.emptySet(); Set resultset = new HashSet(); nameset.removeif((string s) -> s.isempty()); 13 Map

More information

HW#1: Pencil Me In Status!? How was Homework #1? Reminder: Handouts. Homework #2: Java Draw Demo. 3 Handout for today! Lecture-Homework mapping.

HW#1: Pencil Me In Status!? How was Homework #1? Reminder: Handouts. Homework #2: Java Draw Demo. 3 Handout for today! Lecture-Homework mapping. HW#1: Pencil Me In Status!? CS193J: Programming in Java Summer Quarter 2003 Lecture 6 Inner Classes, Listeners, Repaint Manu Kumar sneaker@stanford.edu How was Homework #1? Comments please? SITN students

More information

DEMYSTIFYING PROGRAMMING: CHAPTER FOUR

DEMYSTIFYING PROGRAMMING: CHAPTER FOUR DEMYSTIFYING PROGRAMMING: CHAPTER FOUR Chapter Four: ACTION EVENT MODEL 1 Objectives 1 4.1 Additional GUI components 1 JLabel 1 JTextField 1 4.2 Inductive Pause 1 4.4 Events and Interaction 3 Establish

More information

JAVA NOTES GRAPHICAL USER INTERFACES

JAVA NOTES GRAPHICAL USER INTERFACES 1 JAVA NOTES GRAPHICAL USER INTERFACES Terry Marris 24 June 2001 5 TEXT AREAS 5.1 LEARNING OUTCOMES By the end of this lesson the student should be able to understand how to get multi-line input from the

More information

2110: GUIS: Graphical User Interfaces

2110: GUIS: Graphical User Interfaces 2110: 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

More information

BM214E Object Oriented Programming Lecture 6. Classes and Objects

BM214E Object Oriented Programming Lecture 6. Classes and Objects BM214E Object Oriented Programming Lecture 6 Classes and Objects Classes and Objects Class: describes the form of an object, a template or blueprint or mold specifies data representation, behavior, and

More information

PowerPoint Slides. Object-Oriented Design Using JAVA. Chapter 2. by Dale Skrien

PowerPoint Slides. Object-Oriented Design Using JAVA. Chapter 2. by Dale Skrien PowerPoint Slides Object-Oriented Design Using JAVA by Dale Skrien Chapter 2 Object-oriented Programming Divides the program into a set of communicating objects Encapsulates in an object all the behavior

More information

CS 100J Prelim 2 Have a good break!!! 15 March 2007

CS 100J Prelim 2 Have a good break!!! 15 March 2007 CS 100J Prelim 2 Have a good break!!! 15 March 2007 This 90-minute exam has 6 questions (numbered 0..5) worth a total of 100 points. Spend a few minutes looking at all questions before beginning. Use the

More information