Exam: Applet, Graphics, Events: Mouse, Key, and Focus

Similar documents
Graphical User Interfaces 2

G51PRG: Introduction to Programming Second semester Applets and graphics

CSIS 10A Assignment 14 SOLUTIONS

User interfaces and Swing

Graphics Applets. By Mr. Dave Clausen

CSC System Development with Java Introduction to Java Applets Budditha Hettige

Computer Science 210: Data Structures. Intro to Java Graphics

Building Java Programs

Chapter 14: Applets and More

8/23/2014. Chapter Topics. Introduction to Applets. Introduction to Applets. Introduction to Applets. Applet Limitations. Chapter 14: Applets and More

OBJECT ORIENTED PROGRAMMING. Course 8 Loredana STANCIU Room B613

Chapter 14: Applets and More

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

CSSE 220. Event Based Programming. Check out EventBasedProgramming from SVN

Programming Languages and Techniques (CIS120)

GUI DYNAMICS Lecture July 26 CS2110 Summer 2011

To specify the dimensions of the drawing canvas use the size statement: ! size( 300, 400 );

Unit 7: Event driven programming

Graphical User Interfaces 2

Java Mouse Actions. C&G criteria: 5.2.1, 5.4.1, 5.4.2,

Assignment 2. Application Development

Programming Languages and Techniques (CIS120)

TWO-DIMENSIONAL FIGURES

Graphics Applets. By Mr. Dave Clausen

Graphical User Interfaces 2

Topic 8 graphics. -mgrimes, Graphics problem report 134

Building Java Programs

Building Java Programs

: 15. (x, y) (x, y ) (x, y) ( x x = 1 y = y ) (x = x y y = 1) (12.1.1)

CIS 162 Project 1 Business Card Section 04 (Kurmas)

AP CS Unit 12: Drawing and Mouse Events

Programming Languages and Techniques (CIS120)

Garfield AP CS. Graphics

CSIS 10A Practice Final Exam Solutions

Windows and Events. created originally by Brian Bailey

In this lesson you are going to create a drawing program similar to Windows Paint. 1. Start with a new project and remove the default cat sprite.

THE UNIVERSITY OF AUCKLAND

SAMPLE EXAM Exam 2 Computer Programming 230 Dr. St. John Lehman College City University of New York Thursday, 5 November 2009

Programming Languages and Techniques (CIS120)

Topic 8 Graphics. Margaret Hamilton

Previously, we have seen GUI components, their relationships, containers, layout managers. Now we will see how to paint graphics on GUI components

COSC 123 Computer Creativity. Graphics and Events. Dr. Ramon Lawrence University of British Columbia Okanagan

Heavyweight with platform-specific widgets. AWT applications were limited to commonfunctionality that existed on all platforms.

Building Java Programs

Graphics. Lecture 18 COP 3252 Summer June 6, 2017

UCLA PIC 20A Java Programming

GUI (Graphic User Interface) Programming. Part 2 (Chapter 8) Chapter Goals. Events, Event Sources, and Event Listeners. Listeners

PESIT Bangalore South Campus

H212 Introduction to Software Systems Honors

News! Feedback after Lecture 4! About Java and OOP!

class BankFilter implements Filter { public boolean accept(object x) { BankAccount ba = (BankAccount) x; return ba.getbalance() > 1000; } }

Graphics and Java2D. Objectives

CS 201 Advanced Object-Oriented Programming Lab 1 - Improving Your Image Due: Feb. 3/4, 11:30 PM

2IS45 Programming

An applet is a program written in the Java programming language that can be included in an HTML page, much in the same way an image is included in a

Advanced Internet Programming CSY3020

9. APPLETS AND APPLICATIONS

Programming Languages and Techniques (CIS120)

CS2110. GUIS: Listening to Events

Programming graphics

CS2110. GUIS: Listening to Events. Anonymous functions. Anonymous functions. Anonymous functions. Checkers.java. mainbox

CS2110. GUIS: Listening to Events

1 Definitions & Short Answer (5 Points Each)

CS2110. GUIS: Listening to Events Also anonymous classes versus Java 8 functions. Anonymous functions. Anonymous functions. Anonymous functions

MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question.

Object Oriented Programming

Revit - Conceptual Mass. STEP 1: open Revit _ from the home screen under Families click on New Conceptual Mass _ open the Mass template file

2D Graphics. Shape Models, Drawing, Selection. CS d Graphics 1

Dr. Hikmat A. M. AbdelJaber

Method Of Key Event Key Listener must implement three methods, keypressed(), keyreleased() & keytyped(). 1) keypressed() : will run whenever a key is

Java - Applets. public class Buttons extends Applet implements ActionListener

Java Applet Basics. Life cycle of an applet:

Using Masks for Illustration Effects

Interactive Tourist Map

2D Graphics. Shape Models, Drawing, Selection. CS d Graphics 1

ECE 462 Object-Oriented Programming using C++ and Java. Key Inputs in Java Games

CSIS 10A PRACTICE FINAL EXAM Name Closed Book Closed Computer 3 Sheets of Notes Allowed

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

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!

Paint/Draw Tools. Foreground color. Free-form select. Select. Eraser/Color Eraser. Fill Color. Color Picker. Magnify. Pencil. Brush.

Programming Languages and Techniques (CIS120)

Graphics in Swing. Engineering 5895 Faculty of Engineering & Applied Science Memorial University of Newfoundland

Java - Applets. C&G criteria: 1.2.2, 1.2.3, 1.2.4, 1.3.4, 1.2.4, 1.3.4, 1.3.5, 2.2.5, 2.4.5, 5.1.2, 5.2.1,

Agenda. Programming Seminar. By: dr. Amal Khalifa. Coordinate systems Colors Fonts Drawing shapes Graphics2D API

Using Graphics. Building Java Programs Supplement 3G

Chapter 1 GUI Applications

How to Create a Google Sites Website

Some classes and interfaces used in this chapter from Java s original graphics capabilities and from the Java2D API.

Layouts and Components Exam

CS 2113 Software Engineering

11/7/12. Discussion of Roulette Assignment. Objectives. Compiler s Names of Classes. GUI Review. Window Events

CS 120 Fall 2008 Practice Final Exam v1.0m. Name: Model Solution. True/False Section, 20 points: 10 true/false, 2 points each

Click the buttons in the interactive below to become familiar with the drawing tool's commands.

Using the API: Introductory Graphics Java Programming 1 Lesson 8

ADOBE PHOTOSHOP Using Masks for Illustration Effects

CSCI 053. Week 5 Java is like Alice not based on Joel Adams you may want to take notes. Rhys Price Jones. Introduction to Software Development

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

EXCEPTIONS & GUI. Errors are signals that things are beyond help. Review Session for. -Ankur Agarwal

Adobe photoshop Using Masks for Illustration Effects

Solutions to Chapter Exercises. GUI Objects and Event-Driven Programming

Transcription:

Exam: Applet, Graphics, Events: Mouse, Key, and Focus Name Period A. Vocabulary: Complete the Answer(s) Column. Avoid ambiguous terms such as class, object, component, and container. Term(s) Question(s) Answer(s) repaint() What does this method call? drawarc() Describe the 3 rd parameter, true of ANY arc (d) Describe the last parameter fillpolygon() What is the data type of the first parameter? Describe the 3 rd parameter & The keyboard does not automatically work, even if you implement and add the KeyListener. To make the panel respond to more than the mouse, what method would need to be called? In what key event handler method would you check to see if this had been entered on the keyboard? (c) (c) What key submethod would be used to see if what was entered was exactly &? mousemoved This uses what listener?

B. Drawing: On the graph paper provided, draw the final output. Note that each square on the grid is 10 x 10 pixels. public class RideMore extends JPanel public void paintcomponent(graphics g) int [] xarr = 60, 70, 105; int [] yarr = 85, 70, 80; for(int x = 10; x < 125; x += 95) g.drawoval(x, 80, 60, 60); g.drawline(40, 110, 130, 110); g.drawline(75, 120, 95, 90); g.drawrect(82, 85, 6, 25); g.drawarc(100, 50, 40, 30, 110, -160); g.drawstring("ride more", 20, 170); g.drawpolygon(xarr, yarr, 3);

Programming Accessibility involves the design of products for people with disabilities. You are designing a 1000 pixel wide x 800 pixel tall webpage for a healthcare website. A lot of patients will want to change the font size or background color to make the webpage easier to read. When the up arrow on the keyboard is used, the font size displayed on the screen will become larger by 5 pixels. When the down arrow on the keyboard is used, the font will become smaller by 5 pixels. The user cannot make the font size larger than 80 pixels or smaller than 8 pixels. Use the code shown below (which should be familiar from your reading and practice). You are NOT changing other aspects of color, such as hue,contrast, or saturation. Color c = new Color (amountofred, amountofblue, amountofgreen); //defines a new Color called c setbackground (c); //selects the Color c to be used next with foreground painting such as shapes and font When the user clicks the rectangle titled brighter, the background color of the panel will become brighter by increasing all three parameters by 3.* When the user clicks the rectangle titled darker, the background color of the panel will become darker by decreasing all three parameters by 3.* In this program, use one variable for each of the three parameters (e.g. Color(x, x, x)). (*There are exceptions to this that you should ignore for this program.) The user cannot make the screen lighter than white (defined as Color(255, 255, 255)) and darker than dark grey (defined as Color(34, 34, 34). Complete the code below. You ll find pseudocode to help you know what is missing. You do not need to add pseudocode or a testing plan. You should be writing code as demonstrated in class. A. JFrame File: AccessibilityRunner.java // import each class needed Write the JFrame file needed, including the perfect size so you don t need to resize it.

JPanel class: Accessibility //be sure to complete the class header public class Accessibility private Color backgroundcolor; private int fontsize, colorparamvar; public Accessibility() //add listeners as appropriate backgroundcolor = new Color( 100, 100, 100 ); fontsize = 12; public void drawrectangleswithlabels(graphics g) //This method is complete g.setcolor(color.red); g.fillrect( 10, 10, 100, 20 ); g.fillrect( 115, 10, 100, 20 ); g.setcolor( Color.BLACK ); g.drawstring( brighter, 15, 80 ) g.drawstring( darker, 115, 80 ); public void medicalpagecontent(graphics g) /*Assume this method is complete. */ public void paintcomponent(graphics g) setbackground( backgroundcolor ); //draw background color drawrectangleswithlabels(g); g.setcolor(color.black); Font font = new Font( "Serif", Font.PLAIN, fontsize ); g.setfont( font ); g.drawstring( String to see font change, 50, 300); // this is added in for code on computer medicalpagecontent(g); public void key ( KeyEvent e ) //fill in blank /*determine if the user used the keyboard appropriately to elicit a graphical response, record or change information as appropriate, and call the method to make the appropriate graphical response */

public void key (KeyEvent e) //Fill in blank. public void key (KeyEvent e) //Fill in blank. public void mousepressed(mouseevent e) //make it so the keyboard will work! public void mouseclicked(mouseevent e) /*determine if the user is clicking on one of the appropriate rectangles to elicit a graphical response, record or change information as appropriate, and call the method to make the appropriate graphical response*/ public void mousereleased(mouseevent e) public void mouseentered(mouseevent e) public void mouseexited(mouseevent e)