Java Swing Tooltip addClickTipEffect(final JComponent component)

Here you can find the source of addClickTipEffect(final JComponent component)

Description

add Click Tip Effect

License

Apache License

Declaration

public static void addClickTipEffect(final JComponent component) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.awt.event.MouseEvent;

import javax.swing.JComponent;

public class Main {
    public static void addClickTipEffect(final JComponent component) {
        component.setForeground(new java.awt.Color(51, 51, 255));
        component//ww  w  .  ja v a  2  s  .c o m
                .setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        component.addMouseListener(new java.awt.event.MouseAdapter() {
            @Override
            public void mouseEntered(MouseEvent e) {
                component.setOpaque(true);
                component.setBackground(new java.awt.Color(51, 51, 255));
                component.setForeground(new java.awt.Color(255, 255, 255));
            }

            @Override
            public void mouseExited(MouseEvent e) {
                component.setOpaque(false);
                component.setBackground(new java.awt.Color(255, 255, 255));
                component.setForeground(new java.awt.Color(51, 51, 255));
            }
        });
    }
}

Related

  1. createMarker(int span, String tooltip)
  2. createNumericInput(final String tooltip)
  3. displayTooltip(JComponent component)
  4. hideToolTip(JComponent c)