HELP! * YELLOW=global GREY=local Full HTML for

GLOBAL foilset Jan 29 Delivered Lecture for Course CPS616 -- Java Lecture 3 -- Exceptions Through Events

Given by Nancy McCracken at CPS616 spring 1997 on Jan 29 1997. Foils prepared 1 February 97
Abstract * Foil Index for this file Secs 44.6 See also color IMAGE

Exceptions in some detail
Brief Introduction to Threads (as used in graphics)
Graphics including Image Drawing and Downloading
  • Double Buffering and Flickering of Applets
Abstract Window Toolkit (Started)
  • Mouse and Keyboard Events

Table of Contents for full HTML of Jan 29 Delivered Lecture for Course CPS616 -- Java Lecture 3 -- Exceptions Through Events


1 CPS 616 Java Lectures
with Audio January 29 97
Exceptions Through Events
See:
http://www.npac.syr.edu/users/gcf/cps616-97jan29

2 Abstract of CPS616-97 Lecture of January 29
3 Java Language -- Handling Runtime Errors Using Exceptions
4 Basic Structure of Exception Handling in Nested Calls
5 Examples of Exception Hierarchy
6 Example of Handling Exceptions
7 Classes of Exceptions
8 Exceptions in Applets
9 Java Tutorial - Fall 1996
Part 3: Graphics and the Abstract Windowing Toolkit
http://www.npac.syr.edu/projects/tutorials/Java/

10 Introduction to Threads
11 Example showing the standard thread methods
12 Example showing thread methods, continued
13 Changing Graphics: repaint method
14 The java.awt.Font and FontMetrics Classes
15 Some Basic Methods for Applets -- I
16 Some Basic Methods for Applets -- II
17 A Simple Useful Applet from Sun for Animation
18 Images
and Double Buffering

19 Getting Images Downloaded
20 Drawing Images to the applet window
21 Image Downloading -- imageObserver, MediaTracker
22 An Image Drawing Example
23 Flickering in Applets and its Solution
24 The default Update(Graphics g) Method
25 Double Buffering to Reduce Flicker - I
26 Double Buffering to Reduce Flicker - II
27 Double Buffering
28 Event Handling
29 Events in the java.awt -- Mouse, Keyboard Interaction - I
30 Events in the java.awt -- Mouse, Keyboard Interaction - II
31 Using Mouse Events for User Interaction
32 Mouse Events: Initializing the movable objects
33 Draw the objects with double buffering
34 Mouse Move Event
35 The Set of Mouse Dragging Events
36 More Methods in the Movable Point class
37 Keyboard Events

This table of Contents Abstract



HELP! * YELLOW=global GREY=local HTML version of GLOBAL Foils prepared 1 February 97

Foil 1 CPS 616 Java Lectures
with Audio January 29 97
Exceptions Through Events
See:
http://www.npac.syr.edu/users/gcf/cps616-97jan29

From Jan 29 Delivered Lecture for Course CPS616 -- Java Lecture 3 -- Exceptions Through Events CPS616 spring 1997 -- Jan 29 1997. * See also color IMAGE
Secs 44.6 Full HTML Index
Instructor: Nancy McCracken
teamed with Meryem Ispirli, Geoffrey Fox,
Tom Scavo, John Yip
Syracuse University
111 College Place
Syracuse
New York 13244-4100

HELP! * YELLOW=global GREY=local HTML version of GLOBAL Foils prepared 1 February 97

Foil 2 Abstract of CPS616-97 Lecture of January 29

From Jan 29 Delivered Lecture for Course CPS616 -- Java Lecture 3 -- Exceptions Through Events CPS616 spring 1997 -- Jan 29 1997. * See also color IMAGE
Secs 44.6 Full HTML Index
Exceptions in some detail
Brief Introduction to Threads (as used in graphics)
Graphics including Image Drawing and Downloading
  • Double Buffering and Flickering of Applets
Abstract Window Toolkit (Started)
  • Mouse and Keyboard Events

HELP! * YELLOW=global GREY=local HTML version of GLOBAL Foils prepared 1 February 97

Foil 3 Java Language -- Handling Runtime Errors Using Exceptions

From Jan 29 Delivered Lecture for Course CPS616 -- Java Lecture 3 -- Exceptions Through Events CPS616 spring 1997 -- Jan 29 1997. * See also color IMAGE
Secs 50.4 Full HTML Index
The language itself supports concept of an exception
Java supports a hierarchical model of exceptions which allow and indeed require user to supply suitable handlers for any exception that can occur in a Java program
Note exceptions that can occur in a method must either be caught (i.e. handled inside method) or thrown (i.e. returned to callee)
Thrown exceptions are like returned arguments and are for instance part of interface to a method
Exceptions are all (at some level in hierarchy) subclasses of Throwable class

HELP! * YELLOW=global GREY=local HTML version of GLOBAL Foils prepared 1 February 97

Foil 4 Basic Structure of Exception Handling in Nested Calls

From Jan 29 Delivered Lecture for Course CPS616 -- Java Lecture 3 -- Exceptions Through Events CPS616 spring 1997 -- Jan 29 1997. * Critical Information in IMAGE
Secs 122.4 Full HTML Index
method1 {
  • try {
  • call method2;
  • } catch (Exception3 e) {
  • doErrorProcessing(e);
  • }
}
method2 throws Exception3 {
  • call method3; // method2 just passes exception through
}
method3 throws Exception3 {
  • call dividebyzeroorreadfileorsomething; // create exception
}

HELP! * YELLOW=global GREY=local HTML version of GLOBAL Foils prepared 1 February 97

Foil 5 Examples of Exception Hierarchy

From Jan 29 Delivered Lecture for Course CPS616 -- Java Lecture 3 -- Exceptions Through Events CPS616 spring 1997 -- Jan 29 1997. * Critical Information in IMAGE
Secs 43.2 Full HTML Index
As Examples of hierarchy:
catch(InvalidIndexException e) {..} would catch particular exception whereas
catch(ArrayException e) {..} would catch all Arrayexceptions

HELP! * YELLOW=global GREY=local HTML version of GLOBAL Foils prepared 1 February 97

Foil 6 Example of Handling Exceptions

From Jan 29 Delivered Lecture for Course CPS616 -- Java Lecture 3 -- Exceptions Through Events CPS616 spring 1997 -- Jan 29 1997. * See also color IMAGE
Secs 103.6 Full HTML Index
File file; /* defines file to be object of class File */
try{
  • file = new File("filenameyouwant");
  • . . . . .
  • file.write("stuff put out");
} catch (IOException e) {
  • /* This catches ALL I/O errors including
    • read and write stuff */
  • /* Handle Exception somehow */
return;
}
/* but the optional finally clause will be executed
    • whether or not code terminates normally */
finally {
  • file.close();
}

HELP! * YELLOW=global GREY=local HTML version of GLOBAL Foils prepared 1 February 97

Foil 7 Classes of Exceptions

From Jan 29 Delivered Lecture for Course CPS616 -- Java Lecture 3 -- Exceptions Through Events CPS616 spring 1997 -- Jan 29 1997. * See also color IMAGE
Secs 48.9 Full HTML Index
There are two subclasses of Throwable
  • Error such as OutOfMemoryError which do NOT have to be caught as they are serious but unpredictable and could typically occur anywhere!
  • Exception which we have discussed
Exception has a subclass RuntimeException that need NOT be caught
Typical RuntimeException subclasses are
ArithmeticException ClassCastException IndexOutofBoundException

HELP! * YELLOW=global GREY=local HTML version of GLOBAL Foils prepared 1 February 97

Foil 8 Exceptions in Applets

From Jan 29 Delivered Lecture for Course CPS616 -- Java Lecture 3 -- Exceptions Through Events CPS616 spring 1997 -- Jan 29 1997. * See also color IMAGE
Secs 86.4 Full HTML Index
When writing a Java applet, your code is overriding one of the standard applet methods, and you are not allowed to throw any exceptions that it would not. So, in general, you must handle exceptions.
What to do: The standard trick of writing a message to System.out works fine for debugging when running with the applet viewer. It also works fine with the Netscape browser for errors that you don't really expect to happen in working code (like your code had a null pointer) because Netscape provides a "Java console" under the Options menu that displays all messages.
However, for errors that you really want to bring to the attention of the user, such as they typed in their URL incorrectly and the network methods returned a "malformedURLException", you can put up a pop-up window in the style of professional GUI programs.
Note that you don't have to micromanage exceptions - you don't have to put a "try-catch" construct around every statement that can throw an exception. You can put the "try-catch" around the entire code with the same catch action or even put different catches for different actions of the errors.

HELP! * YELLOW=global GREY=local HTML version of GLOBAL Foils prepared 1 February 97

Foil 9 Java Tutorial - Fall 1996
Part 3: Graphics and the Abstract Windowing Toolkit
http://www.npac.syr.edu/projects/tutorials/Java/

From Jan 29 Delivered Lecture for Course CPS616 -- Java Lecture 3 -- Exceptions Through Events CPS616 spring 1997 -- Jan 29 1997. * See also color IMAGE
Secs 33.1 Full HTML Index
Instructors: Geoffrey Fox ,
Nancy McCracken
Syracuse University
111 College Place
Syracuse
New York 13244-4100

HELP! * YELLOW=global GREY=local HTML version of GLOBAL Foils prepared 1 February 97

Foil 10 Introduction to Threads

From Jan 29 Delivered Lecture for Course CPS616 -- Java Lecture 3 -- Exceptions Through Events CPS616 spring 1997 -- Jan 29 1997. * See also color IMAGE
Secs 256.3 Full HTML Index
A thread is a single sequential flow of control within a process.
If a process has more than one thread, then each thread executes concurrently.
Any Java applet which has extensive execution or loops to repaint the window must run as a concurrent thread with the browser window.
To make an applet with a thread, which is almost always recommended:
  • Change your applet definition to add "implements Runnable", the interface for threads.
  • Include an instance variable for the thread of your applet.
  • Have a start() method which creates a thread and starts it running and a stop() method which stops it running.
  • Have a run() method containing the body of your applet code.

HELP! * YELLOW=global GREY=local HTML version of GLOBAL Foils prepared 1 February 97

Foil 11 Example showing the standard thread methods

From Jan 29 Delivered Lecture for Course CPS616 -- Java Lecture 3 -- Exceptions Through Events CPS616 spring 1997 -- Jan 29 1997. * Critical Information in IMAGE
Secs 555.8 Full HTML Index
These start and stop methods can always be used

HELP! * YELLOW=global GREY=local HTML version of GLOBAL Foils prepared 1 February 97

Foil 12 Example showing thread methods, continued

From Jan 29 Delivered Lecture for Course CPS616 -- Java Lecture 3 -- Exceptions Through Events CPS616 spring 1997 -- Jan 29 1997. * Critical Information in IMAGE
Secs 230.4 Full HTML Index
The body of the applet is in the run method, in this case a loop to keep showing the date.

HELP! * YELLOW=global GREY=local HTML version of GLOBAL Foils prepared 1 February 97

Foil 13 Changing Graphics: repaint method

From Jan 29 Delivered Lecture for Course CPS616 -- Java Lecture 3 -- Exceptions Through Events CPS616 spring 1997 -- Jan 29 1997. * See also color IMAGE
Secs 106.5 Full HTML Index
Most applets and windows applications want to change what is drawn on the screen over its lifetime. This can be a sequenced animation, response to user input or mouse events, and so on.
Whenever you want to redraw the screen, call
  • void repaint();
Repaint gets the graphics context and creates a thread to call update, which calls your paint function. So all your drawing changes are also put into paint.
One draws a sequence of text and shapes to define the screen, where the position of the object in the screen is given by pixel coordinates. If one object overlaps another, the latest one drawn covers up the area of overlap.
  • The exception to this is XOR graphics, which may be used to temporarily highlight a particular color. This is an advanced technique as other colors will also be affected.

HELP! * YELLOW=global GREY=local HTML version of GLOBAL Foils prepared 1 February 97

Foil 14 The java.awt.Font and FontMetrics Classes

From Jan 29 Delivered Lecture for Course CPS616 -- Java Lecture 3 -- Exceptions Through Events CPS616 spring 1997 -- Jan 29 1997. * See also color IMAGE
Secs 83.5 Full HTML Index
Graphicsinstance.setFont(particularFont) will set the current Font in the instance Graphicsinstance of graphics class to the value particularFont of class Font. There are several other such Font related methods in the Graphics class
The class Font has an important constructor used as in
Font particularFont = new Font("TimesRoman",Font.PLAIN,36);
where one can use Courier Helvetica etc. instead of Time Roman
Font.PLAIN, Font.BOLD, Font.ITALIC are possible text styles
FontMetrics fm = getFontMetrics(particularFont); // allows one to find out about the font, such as leading, aspect, etc.
fm.stringWidth("text"); // returns pixel width of string "text"
fm.getHeight(); // returns total height of one line of Font

HELP! * YELLOW=global GREY=local HTML version of GLOBAL Foils prepared 1 February 97

Foil 15 Some Basic Methods for Applets -- I

From Jan 29 Delivered Lecture for Course CPS616 -- Java Lecture 3 -- Exceptions Through Events CPS616 spring 1997 -- Jan 29 1997. * See also color IMAGE
Secs 31.6 Full HTML Index
Some of These are in Applet and some in parent (in particular Component)
public void init() is called ONCE and ONCE only when the applet is loaded or reloaded. Set initial parameters etc. here.
public void destroy() is what you do when Applet is entirely finished and you need to clean up stray threads or connections to be closed.
public void start() is called whenever the applet is started which can happen several times during an applet's life-cycle as it starts each time you revisit a page
public void stop() is called when we temporarily leave Applet to visit another page. A wise move would be to suspend running of Threads to save system resources.

HELP! * YELLOW=global GREY=local HTML version of GLOBAL Foils prepared 1 February 97

Foil 16 Some Basic Methods for Applets -- II

From Jan 29 Delivered Lecture for Course CPS616 -- Java Lecture 3 -- Exceptions Through Events CPS616 spring 1997 -- Jan 29 1997. * See also color IMAGE
Secs 40.3 Full HTML Index
public void paint(Graphics g) actually has an argument and draws what you want on the screen
There is somewhat confusing other methods update() and repaint() which need to used in advanced applications. You may need to call repaint() in a dynamic applet to change display but update() would not need to be called as invoked by repaint(). However update() is sometimes best overridden
public void repaint() is a request by you to the Java runtime to update screen
public void update(Graphics g) is invoked by repaint() and performs the screen update which involves clearing screen and invoking paint()

HELP! * YELLOW=global GREY=local HTML version of GLOBAL Foils prepared 1 February 97

Foil 17 A Simple Useful Applet from Sun for Animation

From Jan 29 Delivered Lecture for Course CPS616 -- Java Lecture 3 -- Exceptions Through Events CPS616 spring 1997 -- Jan 29 1997. * See also color IMAGE
Secs 41.7 Full HTML Index

HELP! * YELLOW=global GREY=local HTML version of GLOBAL Foils prepared 1 February 97

Foil 18 Images
and Double Buffering

From Jan 29 Delivered Lecture for Course CPS616 -- Java Lecture 3 -- Exceptions Through Events CPS616 spring 1997 -- Jan 29 1997. * See also color IMAGE
Secs 8.6 Full HTML Index

HELP! * YELLOW=global GREY=local HTML version of GLOBAL Foils prepared 1 February 97

Foil 19 Getting Images Downloaded

From Jan 29 Delivered Lecture for Course CPS616 -- Java Lecture 3 -- Exceptions Through Events CPS616 spring 1997 -- Jan 29 1997. * Critical Information in IMAGE
Secs 198.7 Full HTML Index
The Applet class provides a method getImage, which retrieves an image from a web server and creates an instance of the Image class.
Image img = getImage(new URL("http://www.tc.com/image.gif"));
Another form of getImage retrieves the image file relative to the directory of the HTML or the directory of the java code.
Image img = getImage(getDocumentBase(), "images/image.gif");
Image img = getImage(getCodeBase(), "images/image.gif");

HELP! * YELLOW=global GREY=local HTML version of GLOBAL Foils prepared 1 February 97

Foil 20 Drawing Images to the applet window

From Jan 29 Delivered Lecture for Course CPS616 -- Java Lecture 3 -- Exceptions Through Events CPS616 spring 1997 -- Jan 29 1997. * Critical Information in IMAGE
Secs 36 Full HTML Index
The Graphics class provides a method drawImage to actually display the image on the browser screen.
You can also scale the image to a particular width and height.

HELP! * YELLOW=global GREY=local HTML version of GLOBAL Foils prepared 1 February 97

Foil 21 Image Downloading -- imageObserver, MediaTracker

From Jan 29 Delivered Lecture for Course CPS616 -- Java Lecture 3 -- Exceptions Through Events CPS616 spring 1997 -- Jan 29 1997. * See also color IMAGE
Secs 56.1 Full HTML Index
When drawImage is called, it draws only the pixels of the image that are already available.
Then it creates a thread for the imageObserver. Whenever more of the image becomes available, it activates the method imageUpdate, which in turn which call paint and drawImage, so that more of the image should show on the screen.
The default imageUpdate doesn't work if you are double buffering the window in which the image appears.
More control over showing the image as it downloads can be obtained by working with the imageObserver class and the new MediaTracker class, using methods which can tell you when the image has fully arrived.

HELP! * YELLOW=global GREY=local HTML version of GLOBAL Foils prepared 1 February 97

Foil 22 An Image Drawing Example

From Jan 29 Delivered Lecture for Course CPS616 -- Java Lecture 3 -- Exceptions Through Events CPS616 spring 1997 -- Jan 29 1997. * Critical Information in IMAGE
Secs 36 Full HTML Index
This example shows how to get the actual height and width of the image to use in scaling the image under java program control.

HELP! * YELLOW=global GREY=local HTML version of GLOBAL Foils prepared 1 February 97

Foil 23 Flickering in Applets and its Solution

From Jan 29 Delivered Lecture for Course CPS616 -- Java Lecture 3 -- Exceptions Through Events CPS616 spring 1997 -- Jan 29 1997. * See also color IMAGE
Secs 103.6 Full HTML Index
Unless you are careful, dynamic applets will give flickering screens
This is due to cycle
paint(g)
update(g) clearing screen
paint(g) drawing new screen .....
where flicker caused by rapid clear-paint cycle.
There are two ways to solve this problem which involve changing update in different ways
  • 1: Change update() either not to clear screen at all (because you know paint() will write over parts that are to be changed) or to just clear the parts of the screen that are changed
  • or 2:Double Buffering

HELP! * YELLOW=global GREY=local HTML version of GLOBAL Foils prepared 1 February 97

Foil 24 The default Update(Graphics g) Method

From Jan 29 Delivered Lecture for Course CPS616 -- Java Lecture 3 -- Exceptions Through Events CPS616 spring 1997 -- Jan 29 1997. * See also color IMAGE
Secs 18.7 Full HTML Index
This sets background color and initializes applet bounding rectangle to this color
  • public void update(Graphics g) {
    • g.setColor(getBackground());
    • g.fillRect(0,0,width,height));
    • g.setColor(getForeground());
    • paint(g);
    • }
getBackground() and getForeground() are methods in component class
fillRect() is a method in Graphics class

HELP! * YELLOW=global GREY=local HTML version of GLOBAL Foils prepared 1 February 97

Foil 25 Double Buffering to Reduce Flicker - I

From Jan 29 Delivered Lecture for Course CPS616 -- Java Lecture 3 -- Exceptions Through Events CPS616 spring 1997 -- Jan 29 1997. * See also color IMAGE
Secs 96.4 Full HTML Index
Here you have two "graphics contexts" (frame buffers of the size of the applet), and you construct the next image for an animation "off-line" in the second frame buffer.
This frame buffer is then directly copied to the main applet Graphics object without clearing image as in default update()
In init(), you would create the frame buffer:
  • Image OffscreenImage; // Place to hold Image
  • Graphics offscreenGraphics; /* The second graphics context of offscreenImage */
  • offscreenImage = createImage(width,height);
  • offscreenGraphics = offscreenImage.getGraphics();

HELP! * YELLOW=global GREY=local HTML version of GLOBAL Foils prepared 1 February 97

Foil 26 Double Buffering to Reduce Flicker - II

From Jan 29 Delivered Lecture for Course CPS616 -- Java Lecture 3 -- Exceptions Through Events CPS616 spring 1997 -- Jan 29 1997. * See also color IMAGE
Secs 82 Full HTML Index
In paint(), one will construct applet image in offscreenGraphics as opposed to the argument g of paint(). So one would see statements such as:
  • offscreenGraphics.drawImage(img,10,10,this);
Finally at end of paint(), one could transfer the off-screen image to g by
  • g.drawImage(offscreenImage,0,0,this);
One would also need to override the update() method by
public void update(Graphics g) {
  • paint(g);
  • }

HELP! * YELLOW=global GREY=local HTML version of GLOBAL Foils prepared 1 February 97

Foil 27 Double Buffering

From Jan 29 Delivered Lecture for Course CPS616 -- Java Lecture 3 -- Exceptions Through Events CPS616 spring 1997 -- Jan 29 1997. * Critical Information in IMAGE
Secs 11.5 Full HTML Index
This technique is most effective in eliminating flicker, but does take longer and use more memory.

HELP! * YELLOW=global GREY=local HTML version of GLOBAL Foils prepared 1 February 97

Foil 28 Event Handling

From Jan 29 Delivered Lecture for Course CPS616 -- Java Lecture 3 -- Exceptions Through Events CPS616 spring 1997 -- Jan 29 1997. * See also color IMAGE
Secs 54.7 Full HTML Index

HELP! * YELLOW=global GREY=local HTML version of GLOBAL Foils prepared 1 February 97

Foil 29 Events in the java.awt -- Mouse, Keyboard Interaction - I

From Jan 29 Delivered Lecture for Course CPS616 -- Java Lecture 3 -- Exceptions Through Events CPS616 spring 1997 -- Jan 29 1997. * See also color IMAGE
Secs 216 Full HTML Index
Events ( distinguish these from Exceptions!) are the way the AWT interacts with the user at mouse or keyboard.
The AWT calls particular event handlers (analogous to exception or interrupt handlers) when user interacts with system in particular ways.
The handling is defined in packages java.awt and java.awt.peer (the machine dependent stuff) with method handleEvent() in class Component(peer)
One could add additional capability here for systems with nifty virtual reality and other user interfaces but we won't cover this here!

HELP! * YELLOW=global GREY=local HTML version of GLOBAL Foils prepared 1 February 97

Foil 30 Events in the java.awt -- Mouse, Keyboard Interaction - II

From Jan 29 Delivered Lecture for Course CPS616 -- Java Lecture 3 -- Exceptions Through Events CPS616 spring 1997 -- Jan 29 1997. * See also color IMAGE
Secs 44.6 Full HTML Index
The Event class has various special class (static) variables defined including
  • Event.F1 -- the F1 key
  • Event.UP The Up arrow etc.
The Component class (grandparent of Applet) has a rich set of Event handlers which you should override if you wish to process particular input
public boolean mouseDown(Event evt, int x, int y) {
  • anchor = new Point(x,y); // record position of mouse click
  • return true; // must do this
  • }
Other handlers are mouseDrag, mouseEnter (enters current component), mouseExit, mouseMove (with its button up), keyUp, keyDown

HELP! * YELLOW=global GREY=local HTML version of GLOBAL Foils prepared 1 February 97

Foil 31 Using Mouse Events for User Interaction

From Jan 29 Delivered Lecture for Course CPS616 -- Java Lecture 3 -- Exceptions Through Events CPS616 spring 1997 -- Jan 29 1997. * Critical Information in IMAGE
Secs 187.2 Full HTML Index
We set up a test program that creates 3 movable objects, a rectangle, circle and triangle, as in the earlier example. In this program, we start with them all red. Whenever the mouse is detected to be over one of the objects, its color is changed to cyan. If the mouse button is used to drag the object, we move the object to the mouse location.
Note that it is not necessary to introduce a thread for this applet since it is not running continuously - it is mostly waiting for mouse events.

HELP! * YELLOW=global GREY=local HTML version of GLOBAL Foils prepared 1 February 97

Foil 32 Mouse Events: Initializing the movable objects

From Jan 29 Delivered Lecture for Course CPS616 -- Java Lecture 3 -- Exceptions Through Events CPS616 spring 1997 -- Jan 29 1997. * Critical Information in IMAGE
Secs 54.7 Full HTML Index

HELP! * YELLOW=global GREY=local HTML version of GLOBAL Foils prepared 1 February 97

Foil 33 Draw the objects with double buffering

From Jan 29 Delivered Lecture for Course CPS616 -- Java Lecture 3 -- Exceptions Through Events CPS616 spring 1997 -- Jan 29 1997. * Critical Information in IMAGE
Secs 113.7 Full HTML Index
In this example, update does all the drawing. It also sets a background color rectangle with a 1 pixel border in the foreground color.

HELP! * YELLOW=global GREY=local HTML version of GLOBAL Foils prepared 1 February 97

Foil 34 Mouse Move Event

From Jan 29 Delivered Lecture for Course CPS616 -- Java Lecture 3 -- Exceptions Through Events CPS616 spring 1997 -- Jan 29 1997. * Critical Information in IMAGE
Secs 205.9 Full HTML Index
Whenever the user moves the mouse, a message is sent from the client workstation to the Java system. It generates a form of interrupt called an event. Your Java applet can choose to provide a method which does appropriate response for any event. This is called an event handler - you must return true to show the general event handler that you have intervened.

HELP! * YELLOW=global GREY=local HTML version of GLOBAL Foils prepared 1 February 97

Foil 35 The Set of Mouse Dragging Events

From Jan 29 Delivered Lecture for Course CPS616 -- Java Lecture 3 -- Exceptions Through Events CPS616 spring 1997 -- Jan 29 1997. * Critical Information in IMAGE
Secs 116.6 Full HTML Index
These handle the sequence of: the user clicks the mouse (mouse down), moves the mouse (mouse drag) and releases the mouse button (mouse up).

HELP! * YELLOW=global GREY=local HTML version of GLOBAL Foils prepared 1 February 97

Foil 36 More Methods in the Movable Point class

From Jan 29 Delivered Lecture for Course CPS616 -- Java Lecture 3 -- Exceptions Through Events CPS616 spring 1997 -- Jan 29 1997. * Critical Information in IMAGE
Secs 28.8 Full HTML Index
We add methods to detect when the mouse is inside an object, and a more general method moveTo for large moves under dragging.

HELP! * YELLOW=global GREY=local HTML version of GLOBAL Foils prepared 1 February 97

Foil 37 Keyboard Events

From Jan 29 Delivered Lecture for Course CPS616 -- Java Lecture 3 -- Exceptions Through Events CPS616 spring 1997 -- Jan 29 1997. * Critical Information in IMAGE
Secs 61.9 Full HTML Index
You may also choose to respond to individual keys being pressed from the keyboard. (Later we will learn of a more general way to handle text input.)

Northeast Parallel Architectures Center, Syracuse University, npac@npac.syr.edu

If you have any comments about this server, send e-mail to webmaster@npac.syr.edu.

Page produced by wwwfoil on Sun Feb 16 1997