How do I assign tool tips for JTabbedPane tabs?

To set a tool tips for JTabbedPane‘s tabs you need to pass the tool tips when adding a new tab to the JTabbedPane. The addTab() method accept the following parameters: the tab’s title, image icon, a component that is going to be the content of the tabs and a string of tool tips information.

When you hover your mouse to the JTabbedPane‘s tabs the tool tips will be shown on the screen. Here is an example how you can can add tool tips the JTabbedPane‘s tabs.

package org.kodejava.example.swing;

import javax.swing.*;
import java.awt.*;

public class TabbedPaneToolTips extends JPanel {
    public TabbedPaneToolTips() {

    private void initializeUI() {
        this.setLayout(new BorderLayout());
        this.setPreferredSize(new Dimension(400, 200));

        JTabbedPane pane = new JTabbedPane();
        ImageIcon tab1Icon = new ImageIcon(
        ImageIcon tab2Icon = new ImageIcon(
        ImageIcon tab3Icon = new ImageIcon(

        JPanel content1 = new JPanel();
        JPanel content2 = new JPanel();
        JPanel content3 = new JPanel();

        // Add tabs to the JTabbedPane. The last parameter in the
        // add tab method is the tool tips for the tabs.
        pane.addTab("Pool", tab1Icon, content1,
                "Pool Game Board");
        pane.addTab("Basketball", tab2Icon, content2,
                "Basketball Game Board");
        pane.addTab("Football", tab3Icon, content3,
                "Football Game Board");

        this.add(pane, BorderLayout.CENTER);

    public static void showFrame() {
        JPanel panel = new TabbedPaneToolTips();

        JFrame frame = new JFrame("JTabbedPane Demo");

    public static void main(String[] args) {
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {


Programmer, runner, recreational diver, live in the island of Bali, Indonesia. Mostly programming in Java, Spring Framework, Hibernate / JPA.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.