Changing the font of all tooltips

You can make a global change to the appearance of several components by using the UIManager class.
To change the font of your ToolTips, set the key ToolTip.font to your desired font.

The easiest way to change the font of only one of your tooltips is to use HTML tags.

Here’s an example of both:

Main.java:

import java.awt.event.*;
import javax.swing.*;
import java.util.*;
import java.awt.*;
 
public class Main extends JFrame {
   public Main() {
      super("JToolTip Change Fonts Demonstration");
 
      getContentPane().setLayout(new GridLayout(2, 1, 30, 30)); 
 
      UIManager.put("ToolTip.font",new Font("SansSerif", Font.ITALIC, 36)); 
 
      JLabel labelSmall = new JLabel("Label with a large ToolTip");
      labelSmall.setToolTipText("Tooltip with a large font");
 
      JLabel labelLarge = new JLabel("Label with an HTML ToolTip");
      labelLarge.setToolTipText("<html><font color=red> HTML ToolTip </font></html>");
         
      getContentPane().add(labelSmall);
      getContentPane().add(labelLarge);
 
      addWindowListener(new WindowAdapter() {
         public void windowClosing(WindowEvent e) {
            System.exit(0);
         }
      });
 
      setSize(450, 300);
   }
 
   public static void main(String[] args) {
      Main main = new Main();
      main.setVisible(true);
   }
}