Question: Write a public class named PutMouseListener that implements the MouseListener * interface. This class will have a public constructor that takes a JComponent as a

Write a public class named PutMouseListener that implements the MouseListener * interface. This class will have a public constructor that takes a JComponent as a * parameter and stores it in an instance variable. Implement the appropriate MouseListener * methods such that the foreground color of the stored JComponent will change to Color.WHITE * when the mouse enters the component, Color.MAGENTA when the mouse exits the component, and * Color.LIGHT_GRAY when the component is clicked. After the component has been clicked is * should remain with a foreground of Color.LIGHT_GRAY regardless of any mouse actions in the * future (Hint: You can do this with a boolean instance variable that tracks whether of not * the component has been clicked). * * Then write a public method in the Problem Set class named mouseComponents_617 that takes * no parameters and returns a new JPanel containing a new JLabel, and a JButton each with a * different instance of PutMouseListener added to it with itself as the JComponent for the * listener. That is, when calling the constructor for PutMouseListener the input should be * the component to which the instance will be added. * * You can/should add this JPanel to a JFrame in your main method to verify the proper * functionality */

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!