Join Patrick Royal for an in-depth discussion in this video My solution: Accessing the mouse, part of Code Clinic: Java.
- In the previous video, we saw how to create music,…but a necessary component of that is being able to detect…where the mouse is and what it's doing.…In particular, we need to be able to know two things:…Where is the mouse cursor on the screen,…and is the mouse button pressed or not?…As it turns out, getting the mouse location is trivial.…In Mouse Music, we use the function…MouseInfo.getPointerInfo().getLocation…to return the current location of the mouse…and that function works regardless of where the mouse is…or what your active window is.…
Unfortunately, determining whether the mouse…is pressed or not is a bit more complicated.…To understand how that works,…let's take a look at the MouseChecker class.…The customizations for this class…start at the class declaration itself.…MouseChecker extends JPanel and implements MouseListener,…two superclasses that provide important functionality…for dealing with the mouse.…Now let's look at the Run method…to see how it utilizes these superclasses.…The first thing we do is set up a new JFrame.…
Patrick introduces challenges and provide an overview of his solutions in Java. Challenges include topics such as statistical analysis, searching directories for images, and accessing peripheral devices.
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
Problem One: Exploring Lake Pend Oreille
Problem Two: Image Analysis
Problem Three: Eight Queens
Problem Four: Accessing Peripherals
Problem Five: Recursion and Directories
Problem Six: Building the Web
- 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.