BFOIT - Introduction to Computer Programming
Background
jLogo Programming
- Commanding a Turtle
- Pseudocode
- Adding New Commands
- Iteration & Animation
- Hierarchical Structure
- Procedure Inputs
- Operators & Expressions
- Defining Operators
- Words & Sentences
- User Interface Events
- What If? (Predicates)
- Recursion
- Local Variables
- Global Variables
- Word/Sentence Iteration
- Mastermind Project
- Turtles As Actors
- Arrays
- File Input/Output
Java
- A Java Program
- What's a Class?
- Extending Existing Classes
- Types
- Turtle Graphics
- Control Flow
- User Interface Events
Appendices
- Jargon
- What Is TG?
- TG Directives
- jLogo Primitives
- TG Editor
- Java Tables
- Example Programs
- *** New ***:
Installation Notes
Updates
- December 13, 2008
- January 6, 2012
- March 15, 2013
- January 20, 2014
- February 13, 2014
- July 29, 2014
- January 18, 2016
- January 29, 2016
- August 19, 2016
Lastly
Java User Interface Events
Introduction
Mouse and Key Events
class TGWexample2 extends TurtleGraphicsWindow
{
public void tgKeyReleased(int keyNum)
{
switch ( keyNum )
{
case TGKeyHandler.DOWN_ARROW:
back( 5 );
break;
case TGKeyHandler.LEFT_ARROW:
left( 5 );
break;
case TGKeyHandler.RIGHT_ARROW:
right( 5 );
break;
case TGKeyHandler.UP_ARROW:
forward( 5 );
break;
}
}
public void tgKeyTyped(char keyChar)
{
switch ( keyChar )
{
case 'd':
setpencolor( BLACK );
pendown();
break;
case 'u':
setpencolor( WHITE );
penup();
break;
}
}
public void tgMouseClicked( int x, int y )
{
System.out.println( "tgMouseClicked( " + x + ", " + y + ")" );
setxy( x, y );
}
public static void main(String[] args)
{
TGWexample2 me = new TGWexample2();
me.setpensize( 8 );
me.setshape( ARROW );
}
} // end class TGWexample2
|
| |
Summary
Go to the Table of Contents