- [Instructor] Our solution consists of three Java classes.…A very small Main class that runs our MouseChecker process.…This main thread will keep running…until MouseChecker is shut down by closing the window.…The MouseChecker class handles our input…and displays our window.…It also has a boolean variable m for mouse…that represents the state of the mouse…seen here in line 13.…
For our logic,…we have decided that true would represent…that the mouse was released after being pressed…and false would represent that the mouse button was pressed.…A mouse pressed event is typically followed quickly…by a mouse released event.…This defines a mouse click.…The mousePressed method,…seen here on line 20,…and mouseReleased method,…seen here on line 27,…as we said,…both will change the value of our boolean variable m…and notify the music object.…
The music object is an instance of the class MouseMusic.…The main feature of this Java class…is to wait inside a while loop…for the value of the boolean variable m…in the MouseChecker class to change…
Visit other courses in the series to see how to solve the exact same challenges in languages like C#, C++, PHP, Python, and Ruby.
Skill Level Intermediate
1. Problem 1: Pond Oreille
2. Problem 2: Where Am I?
3. Problem 3: Eight Queens
4. Problem 4: Accessing Peripherals
5. Problem 5: Facial Recognition
6. Problem 6: Real-Time Information Dashboard
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.