An example of using the colour of pixels in a buffer image to retrieve an object from an ArrayList.
The principle is simple enough: when objects are created and added to the ArrayList you draw a 'hit-area' to a buffer image using a fill colour that 'matches' the index of the object in the ArrayList. This means that rather than doing hit-detection on all your objects each frame you can simply use the colour in the buffer corresponding to the mouse position to directly retrieve the object from the ArrayList and, for example, call a method on that object.
To tweak this sketch, first download it.
Make your updates, then upload your tweak!