0

Is there a way to define a global stylesheet that is used for all my JToolTips throughout my application? If not, how can I define a stylesheet for a tooltip for a single component of which I only know that it is a swing component (JComponent)?

Se Norm
  • 1,715
  • 5
  • 23
  • 40

1 Answers1

1

If you want to change the color for tooltip, there are several look and feel defaults properties with keys:

ToolTip.background
ToolTip.backgroundInactive
ToolTip.border
ToolTip.borderInactive
ToolTip.font
ToolTip.foreground
ToolTip.foregroundInactive

e.g. For set the new color for foreground

UIManager.put("ToolTip.foreground",java.awt.Color.red);

e.g. in one application I have these defaults

ToolTip.background   =>     javax.swing.plaf.ColorUIResource[r=184,g=207,b=229]
ToolTip.backgroundInactive   =>     javax.swing.plaf.ColorUIResource[r=238,g=238,b=238]
ToolTip.border   =>     javax.swing.plaf.BorderUIResource$LineBorderUIResource@da18ac
ToolTip.borderInactive   =>     javax.swing.plaf.BorderUIResource$LineBorderUIResource@8a0544
ToolTip.font     =>     javax.swing.plaf.FontUIResource[family=Dialog,name=Dialog,style=plain,size=12]
ToolTip.foreground   =>     sun.swing.PrintColorUIResource[r=51,g=51,b=51]
ToolTip.foregroundInactive   =>     javax.swing.plaf.ColorUIResource[r=122,g=138,b=153]
BenMorel
  • 34,448
  • 50
  • 182
  • 322
Paul Vargas
  • 41,222
  • 15
  • 102
  • 148