Change tool tip font

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
SystemsEngineer
Posts: 16
Joined: Thu Jan 19, 2017 5:54 pm
antibot: No, of course not.

Change tool tip font

Post by SystemsEngineer » Tue Apr 25, 2017 2:29 pm

Hello,

Is it possible to change the font of a chart tool tip (of a series or a legend)?

Thanks a lot!

John Matthews
Posts: 513
Joined: Wed Sep 12, 2007 3:18 pm

Re: Change tool tip font

Post by John Matthews » Tue Apr 25, 2017 9:11 pm

JFreeChart uses Swing tooltips. The font is specified by the JToolTip UI delegate, typically a subclass of BasicToolTipUI. Use the UIManager, as shown here, to change the relevant property, which has the key "ToolTip.font".

SystemsEngineer
Posts: 16
Joined: Thu Jan 19, 2017 5:54 pm
antibot: No, of course not.

Re: Change tool tip font

Post by SystemsEngineer » Wed Apr 26, 2017 12:44 pm

Thank you very much for your response.

I tried to change the global UI font for the tooltips doing something like
UIManager.put("ToolTip.font", new FontUIResource("SansSerif", Font.BOLD, 28));
but the tooltips remained unaffected.

However, it seems that, when used within a JavaFX app, the JFreeChart's tooltip behavior depends on the tooltip configuration of the app and not the Swing UI because as soon as I modified the global font of the JavaFX tooltip, the problem was solved!

John Matthews
Posts: 513
Joined: Wed Sep 12, 2007 3:18 pm

Re: Change tool tip font

Post by John Matthews » Thu Apr 27, 2017 1:29 am

Thank you for the followup. It would seem that ChartPanel uses Swing Tooltips, while ChartViewer uses JavaFX tooltips.

Under Swing, it's important to make any UIManager changes on the initial thread, before starting the EventQueue.

prize
Posts: 3
Joined: Wed Jun 21, 2017 6:20 pm
antibot: No, of course not.
Contact:

Re: Change tool tip font

Post by prize » Wed Jun 21, 2017 6:35 pm

Thank for tips. I've thinking how to change tool font from a while.

Locked