Welcome to Computer Programming

HWJ7 - MouseMotion

Create these programs: 2 points each -do 4 of 7

  1. In FindLocation2, have 2 textfields, and if the mouse is moved around the screen the coordinates appear in each textfield. If the mouse is dragged (meaning button is down), have the buttons change background color. [xField.setBackground(Color.green);] Starter
  2. Create SnowMan that has a small SnowMan follow the cursor around (draw on temporary layer Graphics g=getTempG() ). (A snowman could be just three circles on top of each other - or an image) Starter
  3. In AnnoyTheUser have a circle that appears at a random location. When the user moves the cursor close to the circle (say within 30 pixels), the circle will move to a new random location. Fun.
  4.   Starter
  5. In Rainbow have a rainbow of colors appear when the user moves the mouse. It will be beautiful; kind of like a rainbow.Use g.setColor(Color.blue) or any color Have a reset button.  Starter
  6. In DrawDynamicRect that when the user presses down and then drags their mouse it will constantly draw (and erase) a rectangle that is that size. When they release the mouse, it will finalize that rectangle. (code will be in mousepressed, mousedragged and mousereleased) [advanced - have it work in any direction]//Code to get a random color g.setColor(findRandomColor()); Starter
  7. In Gradient that when the mouse is moved left or right, it will adjust the amount of red in the background. If it goes up or down, it will adjust the amount of green.g.setColor(new Color(r,g,b) where r,g,b are the amount of red green and blue) Starter
  8. In ConstantLine when the mouse is pressed it will start drawing a new line and connect the dots to make the line like good. (so there is no gaps). Each time they press down, a new line will be drawn.Starter


  1. In Operation, there will be a square inside a square. The idea of the game is that the user must move their mouse around the inside of the square without hitting the walls. It will keep track of how much time it takes for them to accomplish this goal. Put this inside paintScreen:
    You probably will want to have a global int corner; Where whenever they make it to a corner it will change which corner you need to hit next. This is hard, but oh what a fun game it would be. Timer here That part is required. Additional ideas: