Here you can find the source of setHintOnMouseHover(JComponent view, String tooltip, JLabel onView)
public static void setHintOnMouseHover(JComponent view, String tooltip, JLabel onView)
//package com.java2s; //License from project: Apache License import javax.swing.*; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; public class Main { public static void setHintOnMouseHover(JComponent view, String tooltip, JLabel onView) { view.addMouseListener(new MouseAdapter() { @Override/*from w w w .j a v a 2s . c om*/ public void mouseEntered(MouseEvent e) { super.mouseEntered(e); onView.setText(tooltip); } @Override public void mouseExited(MouseEvent e) { super.mouseExited(e); onView.setText(""); } // @Override // public void mouseMoved(MouseEvent e) { // super.mouseMoved(e); // onView.setText(tooltip); // } }); } }