More Events.

Slides:



Advertisements
Similar presentations
Instruction: Use mouses left button. Use mouses left button. If mouse buttons dont work, use arrow keys of keyboard for slide show. If mouse buttons dont.
Advertisements

Instruction: Use mouses left button. Use mouses left button. If mouse buttons dont work, use arrow keys of keyboard for slide show. If mouse buttons dont.
Intro to Computers!.
Review! This is for your test, so pay attention!.
1 Loops. 2 Often we want to execute a block of code multiple times. Something is always different each time through the block. Typically a variable is.
CMPUT 101 Lab # 5 October 22, :00 – 17:00.
Week 2: Primitive Data Types 1.  Programming in Java  Everything goes inside a class  The main() method is the starting point for executing instructions.
Exploring Events. Try this Start Alice and create a blank world using the grass template. Add an instance of a BlueBallerina. Add an instance of a PinkBallerina.
How to Debug VB .NET Code.
Alice Learning to program: Part 1 Scene Setup and Starting Animation by Ruthie Tucker and Jenna Hayes Under the direction of Professor Susan Rodger Duke.
Fundamentals of Programming in Visual Basic 3.1 Visual basic Objects Visual Basic programs display a Windows style screen (called a form) with boxes into.
Conversational Computers
Microsoft ® Office PowerPoint ® 2003 Training Create your first Presentation Mr Garel…… presents:
An Introduction to Textual Programming
Introduction to Graphical User Interfaces. Objectives * Students should understand what a procedural program is. * Students should understand what an.
Week 2 - Monday.  What did we talk about last time?  Software development  Lab 1.
The string data type String. String (in general) A string is a sequence of characters enclosed between the double quotes "..." Example: Each character.
KeyListener and Keyboard Events Another type of listener listens for keyboard entry – the KeyListener which generates KeyEvents –to implement KeyListener,
5 BASIC CONCEPTS OF ANY PROGRAMMING LANGUAGE Let’s get started …
Chapter 10: Applets and Advanced Graphics The Applet Class The Applet Class The HTML Tag The HTML Tag Passing Parameters to Applets Passing Parameters.
Comments in Java. When you create a New Project in NetBeans, you'll notice that some text is greyed out, with lots of slashes and asterisks:
CS140: Intro to CS An Overview of Programming in C (part 3) by Erin Chambers.
Lec 16 Adding Mouse and KeyEvent handlers to an Applet Class.
CS140: Intro to CS An Overview of Programming in C by Erin Chambers.
Understand the difference between applets and applications Identify meaningful applet resources for academic subjects Create and demonstrate a basic Java.
Objective: Students will be able to: Declare and use variables Input integers.
Advanced Stuff Learning by example: Responding to the mouse.
Unit 2 Test: Tues 11/3. ASCII / Unicode –Each letter, symbol, etc has a # value –See ascii table (in folder) –To convert a char into its ascii value,
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 4: Events Programming with Alice and Java First Edition by John Lewis.
Learning to Program: Part 1 Scene Setup and Starting Animation by Ruthie Tucker and Jenna Hayes Under the direction of Professor Susan Rodger Duke University,
Welcome to AP Computer Science A We use the Java language, but this class is much more rigorous than Intro to Java More programming, but also more theory.
Web Programming Overview. Introduction HTML is limited - it cannot manipulate data How Web pages are extended (include): –Java: an object-oriented programming.
5 Event Handling Interactive Programming Suggested Reading Interaction: Events and Event Handling, Supplemental Text for CPSC 203 Distributed this term.
1.1: Objects and Classes msklug.weebly.com. Agenda: Attendance Let’s get started What is Java? Work Time.
Input Characters from the Keyboard tMyn1 Input Characters from the Keyboard We have been using console output, but not console (keyboard) input. The main.
National Diploma Unit 4 Introduction to Software Development Procedures and Functions.
Chapter 1 Object Orientation: Objects and Classes.
Chapter 2 Variables and Constants. Objectives Explain the different integer variable types used in C++. Declare, name, and initialize variables. Use character.
Copyright © Texas Education Agency, Computer Programming Variables and Data Types.
THE MOUSE Left Click THE MOUSE Right Click.
Introduction to Programming
Chapter 4 - Finishing the Crab Game
Week 2 - Wednesday CS 121.
How Computers Store Variables
Games Programming in Scratch
Applets.
Intro Now you are in my classroom and in a “breakout” room (it’s a separate “study” area) Let’s check out some of the features…. (click on the “next page”
RAD Certification Checkpoint #2 Introducing RadStudio (Hello World)
Debugging and Random Numbers
Multiple variables can be created in one declaration
Encoding Through the Keyboard
Connections Reading Strategy 7.11.
CS/COE 0449 (term 2174) Jarrett Billingsley
Agenda Warmup Lesson 2.5 (Ascii, Method Overloading)
Miscellaneous Topics #6: Polygons GUI Components and Event Handlers
Vehicles and Conditionals
CS 106A, Lecture 14 Events and Instance Variables
Lesson 2: Building Blocks of Programming
Week 2 Keyboard Orientation.
Variables Numbers can be stored and retrieved while a program is running if they are given a home. The way that integers and decimal numbers are stored.
Using to speed up the work process!
Problem Solving Designing Algorithms.
Whatcha doin'? Aims: Begin to create GUI applications. Objectives:
ICT Gaming Lesson 3.
User Input Keyboard input.
Java Lessons Mr. Kalmes.
Makey Makey!.
Explain what touch develop is to your students:
AP Java Unit 3 Strings & Arrays.
Variables and Constants
Presentation transcript:

More Events

Keyboard Events Now that you’re an expert on MouseEvents, let’s try the keyboard. There are many similarities so this lesson will be a little different.

Keyboard Events This might seem a little backwards, but here we go: Open KeyboardAndFocusDemo.java file from DocSharing and run it.

Keyboard Events Press the right and left arrow keys, as well as the “g” and “b” keys. What happens? (If nothing, you need to click on the applet first.)

Keyboard Events Keyboard events are very similar to Mouse events. There are some differences, and the following notes discuss some things you’ll see in the code.

Keyboard Events Events are classes that have methods. One method you’ll see is getKeyChar(). This gets the character (letter) from the key, and usually stores it in a “char” variable.

Keyboard Events “char” types can be compared using the == test: if(char == ‘B’) tests if the character is the same as CAPITAL B.

Keyboard Events Sometimes keys don’t have characters. For example, the “arrow” keys. For those, we use getKeyCode() These return an integer, so you’ll see it stored like: int key = evt.getKeyCode();

Keyboard Events To use keys like the arrow keys, Java made a “virtual key” for them. The following code compares the key “heard” to the left arrow key: int key = evt.getKeyCode(); if (key == KeyEvent.VK_LEFT) //do something…

Java - Assignment And that’s all of the new information. Now it’s time to apply these notes, and those from Applets, Graphics, and Mouse Events! Please head over to the Key Lab!