Creating the "Image" button pressed / pressed in Swing

I created a JButton that has an image defined as an icon representing a button. Now i installed

setContentAreaFilled(false); setBorderPainted(false); setOpaque(false); 

properties that make the image button beautiful, without borders or background colors, etc.

Now the problem is that when I click on the image, it does not show the effects of clicking the button, so when there is some kind of background processing or some kind of event is fired when the button is pressed, which takes time to process the request and return something , it seems that the button has not been pressed, and the user can continue to click it.

How to create a button that has a set of icons with the above properties, and yet I have some control over how to configure onpress or onmouseover events.

+8
java swing icons jbutton
source share
1 answer

I found the answer: setRolloverIcon() and setPressedIcon() will do the magic.

+7
source share

All Articles