Example usage for javax.swing ToolTipManager setReshowDelay

List of usage examples for javax.swing ToolTipManager setReshowDelay

Introduction

In this page you can find the example usage for javax.swing ToolTipManager setReshowDelay.

Prototype

public void setReshowDelay(int milliseconds) 

Source Link

Document

Used to specify the amount of time before the user has to wait initialDelay milliseconds before a tooltip will be shown.

Usage

From source file:Main.java

public static final void emphasizeToolTip() {
    ToolTipManager toolTipManager = ToolTipManager.sharedInstance();
    toolTipManager.setDismissDelay(100000);
    toolTipManager.setInitialDelay(10);//ww w. jav  a2 s  . c o m
    toolTipManager.setReshowDelay(10);
}

From source file:net.sf.xmm.moviemanager.gui.DialogIMDB.java

JPanel createMoviehitsList() {
    /* Movies List panel...*/
    JPanel panelMoviesList = new JPanel();
    panelMoviesList.setBorder(BorderFactory.createCompoundBorder(
            BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(),
                    Localizer.get("DialogIMDB.panel-movie-list.title")), //$NON-NLS-1$
            BorderFactory.createEmptyBorder(5, 5, 5, 5)));

    listMovies = new JList() {

        public String getToolTipText(MouseEvent e) {

            if (getCellBounds(0, 0) == null)
                return null;

            String retVal = null;

            int row = (int) e.getPoint().getY() / (int) getCellBounds(0, 0).getHeight();

            if (row >= 0 && row < getModel().getSize()
                    && getMoviesList().getModel().getElementAt(row) instanceof ModelIMDbSearchHit) {
                retVal = ((ModelIMDbSearchHit) getMoviesList().getModel().getElementAt(row)).getAka();

                if (retVal != null && retVal.trim().equals("")) //$NON-NLS-1$
                    retVal = null;//from   w  w w  .  ja va2 s . c om
            }

            return retVal;
        }

        public JToolTip createToolTip() {
            JMultiLineToolTip tooltip = new JMultiLineToolTip();
            tooltip.setComponent(this);
            return tooltip;
        }
    };

    // Unfortunately setting tooltip timeout affects ALL tooltips
    ToolTipManager ttm = ToolTipManager.sharedInstance();
    ttm.registerComponent(listMovies);
    ttm.setInitialDelay(0);
    ttm.setReshowDelay(0);

    listMovies.setFixedCellHeight(18);

    listMovies.setFont(new Font(listMovies.getFont().getName(), Font.PLAIN, listMovies.getFont().getSize()));
    listMovies.setLayoutOrientation(JList.VERTICAL);
    listMovies.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    listMovies.setCellRenderer(new MovieHitListCellRenderer());

    listMovies.addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent event) {

            // Open we page
            if (SwingUtilities.isRightMouseButton(event)) {

                int index = listMovies.locationToIndex(event.getPoint());

                if (index >= 0) {
                    ModelIMDbSearchHit hit = (ModelIMDbSearchHit) listMovies.getModel().getElementAt(index);

                    if (hit.getUrlID() != null && !hit.getUrlID().equals("")) {
                        BrowserOpener opener = new BrowserOpener(hit.getCompleteUrl());
                        opener.executeOpenBrowser(MovieManager.getConfig().getSystemWebBrowser(),
                                MovieManager.getConfig().getBrowserPath());
                    }
                }
            } else if (SwingUtilities.isLeftMouseButton(event) && event.getClickCount() >= 2) {
                buttonSelect.doClick();
            }
        }
    });

    KeyStroke enterKeyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0, true);
    ActionListener listKeyBoardActionListener = new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            log.debug("ActionPerformed: " + "Movielist - ENTER pressed."); //$NON-NLS-1$
            buttonSelect.doClick();
        }
    };
    listMovies.registerKeyboardAction(listKeyBoardActionListener, enterKeyStroke, JComponent.WHEN_FOCUSED);

    JScrollPane scrollPaneMovies = new JScrollPane(listMovies);
    scrollPaneMovies.setAutoscrolls(true);
    //scrollPaneMovies.registerKeyboardAction(listKeyBoardActionListener,enterKeyStroke, JComponent.WHEN_FOCUSED);

    panelMoviesList.setLayout(new BorderLayout());
    panelMoviesList.add(scrollPaneMovies, BorderLayout.CENTER);

    return panelMoviesList;
}

From source file:com.isti.traceview.common.TraceViewChartPanel.java

/**
 * Handles a 'mouse exited' event. This method resets the tooltip delays of
 * ToolTipManager.sharedInstance() to their original values in effect before mouseEntered()
 * /* w w  w .  j  a  v a 2s.com*/
 * @param e
 *            the mouse event.
 */
public void mouseExited(MouseEvent e) {
    if (this.ownToolTipDelaysActive) {
        // restore original tooltip dealys
        ToolTipManager ttm = ToolTipManager.sharedInstance();
        ttm.setInitialDelay(this.originalToolTipInitialDelay);
        ttm.setReshowDelay(this.originalToolTipReshowDelay);
        ttm.setDismissDelay(this.originalToolTipDismissDelay);
        this.ownToolTipDelaysActive = false;
    }
}

From source file:com.isti.traceview.common.TraceViewChartPanel.java

/**
 * Handles a 'mouse entered' event. This method changes the tooltip delays of
 * ToolTipManager.sharedInstance() to the possibly different values set for this chart panel.
 * //from  ww w  . j  av a 2 s .c om
 * @param e
 *            the mouse event.
 */
public void mouseEntered(MouseEvent e) {
    if (!this.ownToolTipDelaysActive) {
        ToolTipManager ttm = ToolTipManager.sharedInstance();

        this.originalToolTipInitialDelay = ttm.getInitialDelay();
        ttm.setInitialDelay(this.ownToolTipInitialDelay);

        this.originalToolTipReshowDelay = ttm.getReshowDelay();
        ttm.setReshowDelay(this.ownToolTipReshowDelay);

        this.originalToolTipDismissDelay = ttm.getDismissDelay();
        ttm.setDismissDelay(this.ownToolTipDismissDelay);

        this.ownToolTipDelaysActive = true;
    }
}

From source file:com.rapidminer.gui.plotter.charts.AbstractChartPanel.java

/**
 * Handles a 'mouse exited' event. This method resets the tooltip delays of
 * ToolTipManager.sharedInstance() to their original values in effect before mouseEntered()
 * //from ww w. j  a va2  s  . co  m
 * @param e
 *            the mouse event.
 */

@Override
public void mouseExited(MouseEvent e) {
    if (this.ownToolTipDelaysActive) {
        // restore original tooltip dealys
        ToolTipManager ttm = ToolTipManager.sharedInstance();
        ttm.setInitialDelay(this.originalToolTipInitialDelay);
        ttm.setReshowDelay(this.originalToolTipReshowDelay);
        ttm.setDismissDelay(this.originalToolTipDismissDelay);
        this.ownToolTipDelaysActive = false;
    }
}

From source file:com.rapidminer.gui.plotter.charts.AbstractChartPanel.java

/**
 * Handles a 'mouse entered' event. This method changes the tooltip delays of
 * ToolTipManager.sharedInstance() to the possibly different values set for this chart panel.
 * /*from w ww. ja v  a  2 s .c  om*/
 * @param e
 *            the mouse event.
 */

@Override
public void mouseEntered(MouseEvent e) {
    if (!this.ownToolTipDelaysActive) {
        ToolTipManager ttm = ToolTipManager.sharedInstance();

        this.originalToolTipInitialDelay = ttm.getInitialDelay();
        ttm.setInitialDelay(this.ownToolTipInitialDelay);

        this.originalToolTipReshowDelay = ttm.getReshowDelay();
        ttm.setReshowDelay(this.ownToolTipReshowDelay);

        this.originalToolTipDismissDelay = ttm.getDismissDelay();
        ttm.setDismissDelay(this.ownToolTipDismissDelay);

        this.ownToolTipDelaysActive = true;
    }
}