4
How do I change the background and text color of a Tooltip? I already did a search and found here a chunk of code but I can’t change it. Colors always stay the default Netbeans. Any suggestions?
I put the following code in the constructor of my class:
UIManager.put("ToolTip.foreground", Color.BLACK);
UIManager.put("ToolTip.background", Color.GREEN);
ToolTipManager.sharedInstance().setInitialDelay(0);
ToolTipManager.sharedInstance().setDismissDelay(1500);
jFormattedNIPC.setToolTipText("teste");
Updating:
Use HTML in the field properties in the Tooltiptext section. The color has changed well, but the background looks like this:
Background color does not fill the 'balloon' completely.
Code used: <html><p style='background-color:blue; color:white;'>teste</p></html>
Some elements of swing accept HTML in the text. For example in a label you can put something like this in the text:
"<html>Palavra em <strong>negrito</strong>.</html>"
. Tried to put that in your tooltip?– Franchesco
I didn’t use any type of HTML in my code. I’ll try this one. But at the color level what would be the code? I’m just not really into HTML. Thanks in advance! IT WORKS BOLD !! : ) I need the colors for background and text :)
– Hugo Machado
Change the color of the text already managed, I miss the tooltip background.
– Hugo Machado