Java Swing Mouse setHintOnMouseHover(JComponent view, String tooltip, JLabel onView)

Here you can find the source of setHintOnMouseHover(JComponent view, String tooltip, JLabel onView)

Description

set Hint On Mouse Hover

License

Apache License

Declaration

public static void setHintOnMouseHover(JComponent view, String tooltip, JLabel onView) 

Method Source Code


//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);
            //            }
        });
    }
}

Related

  1. removePopup(JComponent mouseEvtComp)
  2. retargetMouseEvent(int id, MouseEvent e, Component target)
  3. retargetMouseEvent(int id, MouseEvent e, Component target)
  4. retargetMouseEvent(MouseEvent e, Component target)
  5. rowAtPoint(MouseEvent mouseEvent)
  6. shouldIgnore(MouseEvent me, JComponent c)
  7. swingDispatch(MouseEvent e, Component component)