Title: Mouse Interfaces: Spots Painting
Course: CPS 161: An Intro to Programming with Java - DL MM MASTER > Section: Learning Units - Bb

Presentations and Videos

- Mouse Interfaces: Spots Painting lecture video (Time: 38:50)
- Mouse Interfaces: Spots Painting document

- Have some class implement the desired interface such as MouseListener
- Add all of the methods required to properly implement the interface (i.e. MouseListener)
- In the added methods, you can find out information about the mouse through the parameter MouseEvent.
- Call addMouseListener to inform the system about the class which can be called for mouse activity.
- A call to repaint will cause the system to call your paint routine again.
- Several examples are created: Spots.java, SpotsSave.java.
- A brief introduction is made of the flexible array approach using the class ArrayList.
- To detect Mouse Motion and dragging, we add one more interface called MouseMotionListener to create the example SpotsArt.java