How to get a tooltip / pop-up effect on a button?

How to get mouseover effects on JButton, which should be similar to the effect that we get on labeling in Stackoveflow? For instance.

Pop-up help

+3
source share
3 answers

See JComponent.setToolTipText(String). The tooltip supports HTML to some extent, but not to the extent of providing link functionality at the bottom of the SO tag pop-ups.

To do this, you will need to change the hint for JWindow/ JEditorPane, where you will need to “bind this together” yourself. Here is an example in which it is used JWindow(to display instances BufferedImage).

swfIz.gif

+5
source
Icon normalIcon = new ImageIcon("normal-icon.png"); // Icon for normal situations
JButton button = new JButton(); // initialize the button
button.setIcon(normalIcon); // set the normal situation icon

Icon rollOverIcon = new ImageIcon("roll-over.png"); // Icon for roll over (hovering effect)
button.setRolloverIcon(rollOverIcon); // Set the icon attaching with the roll-over event
+1
source

All Articles