1

I have a program with two sets of tooltips:

  • Normal Tooltips that describe a JLabel in more depth
  • Tooltips that signify errors - these should have a red background color.

I know how to set the background color of a tooltip by using UIManager, but that changes the background of all of the tooltips, something that I don't want to do.

Cole
  • 109
  • 1
  • 2

2 Answers2

2

You can Use HTML in Swing Components, including tool tips.

Addendum: There's a nice example here.

Community
  • 1
  • 1
trashgod
  • 203,806
  • 29
  • 246
  • 1,045
  • This worked. I was not aware that one could use simple CSS in Swing components. Thanks! – Cole Jun 20 '11 at 19:20
1

You could add a custom mouse listener that would display the other tool-tip.

However, this sounds a little confusing to the user.

jzd
  • 23,473
  • 9
  • 54
  • 76
  • I need the two categories of ToolTips to have different background colors. The display event shouldn't change. – Cole Jun 20 '11 at 15:35
  • Do you want to show both at the same time? Does the error message take precedence? – jzd Jun 20 '11 at 15:44