I have 2 imageIcon for one JLabel and I just did that when I clicked it the imageIcon will change, but I just what to do that the imageIcon will change vice versa when you click it repeatedly. Is it possible that the JLabel first imageIcon alternating to the second imageIcon when you clicked?
I'm doing it for switch image that turns on and off and I coded it in class that extends JLabel.
Thanks for help in advance and sorry for my explanation and English.
Instead of reinventing the wheel, I recommend you use a JToggleButton. You can set the icon and the pressedIcon, and if you want the appearance of a label, you can set whether the border is painted and whether the contentArea is filled.
There are no new questions, but there may be new answers.
if you DO want to use a JLabel, then simply add a MouseListener to this label. In the ML-code, every time the label is clicked, change the icon of the label. In this way, you can use as many icons as you like.