Re: Changing the font of tool tip text



In article <4v2k87F1aosl9U1@xxxxxxxxxxxxxxxxxx>,
Thomas Kellerer <TAAXADSCBIXW@xxxxxxxxxxxxx> wrote:

qu0ll wrote on 22.12.2006 10:28:
Is it possible to change the properties of the font used in displaying tool
tip text for a JComponent?


You could override createToolTip() and then set the Font:

public JTooltip createToolTip()
{
JToolTip tip = super.createToolTip();
tip.setFont(myFont);
return tip;
}

haven't tried this though.


If you want to change it globally, you can do this by applying the necessary
UIDefaults *before* creating the first Swing Component.

UIDefaults def = UIManager.getDefaults();
def.put("ToolTip.font", myFont);

Thomas

As to the UIDefaults part, I'm pretty sure I've read that the preferred
way of doing what's suggested here would be to use a FontUIResource
rather than a Font. The former subclasses the latter, and its API
Javadoc description says that "UI classes which set default font
properties should use this class." It has constructors accepting a Font
or the name, style and size as can be used with a Font.

= Steve =
--
Steve W. Jackson
Montgomery, Alabama
.