Project 7: Mouse Methods

Before you begin, create a folder in your Projects Folder called Firstname.LastName.project7. Do a File...Save as this html document into your Project7 folder. Comment out each line or section of java code on anything you do using the /* (insert comments here) and */ symbols.

Intro: The purpose of this applet is to introduce you to an Event in java. An Event is when something happens. In this applet the Event you are going to be writing code for is user clicks their mouse in the applet space and drags the mouse around the space. You will have to create an applet that 'listens' for when and where the mouse is clicked down and also 'listens' for where the user drags it to on the applet screen. You can choose one of two techniques:

For both techniques, once you have captured the Event or MouseEvent in memory, you will have to use the getGraphics() method of java.awt.Component and the drawLine() method of java.awt.Graphics to make the users line appear.

1. Create an applet in the space below that allows the user to draw lines with their mouse by dragging the applet area. You will need to import java.applet and java.awt.

Save a copy of your entire folder into the Project 7 Folder on the server. You should have a project7.java file, a project7.class file and a project7.htm file. Make sure the folder has your Firstname.Lastname.project7 as a title. Open up your project on the server in a browser to make sure it appears the way your want it.