MouseListener Help Java
Any Component can have a MouseListener. JLabel is nice for a colored rectangle, as long as you make it opaque. Addendum: Having recommended MouseAdapter elsewhere, I should mention that one instance is enough. Addendum: This update adds the mouse listener in the ColorLabel constructor. import java.awt.Color; import java.awt.Dimension; import java.awt.EventQueue; import java.awt.GridLayout; import java.awt.event.MouseAdapter; import … Read more