/** * Distribution License: * BibleDesktop is free software; you can redistribute it and/or modify it under * the terms of the GNU General Public License, version 2 as published by * the Free Software Foundation. This program is distributed in the hope * that it will be useful, but WITHOUT ANY WARRANTY; without even the * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU General Public License for more details. * * The License is available on the internet at: * http://www.gnu.org/copyleft/gpl.html * or by writing to: * Free Software Foundation, Inc. * 59 Temple Place - Suite 330 * Boston, MA 02111-1307, USA * * Copyright: 2005 * The copyright to this program is held by it's authors. * * ID: $Id: URIEventListener.java 1966 2009-10-30 01:15:14Z dmsmith $ */ package org.crosswire.bibledesktop.display; import java.util.EventListener; import javax.swing.ToolTipManager; //import javax.swing.JToolTip; /** * Implement URIEventListener to recieve URIEvents whenever someone activates an * URI. * * @see gnu.gpl.License for license details.
* The copyright to this program is held by it's authors. * @author DM Smith [dmsmith555 at yahoo dot com] */ public class HyperlinkTip implements URIEventListener { int formerInitialDelay; int formerDismissDelay; String formerTip; int myInitialDelay=2000; int myDismissDelay=60000; //The display, say a Bible Text Display BookDataDisplay display; public HyperlinkTip(BookDataDisplay bdd){ bdd.addURIEventListener(this); display = bdd; } /** * This method is called to indicate that an URI can be processed. * * @param ev * Describes the URI */ void activateURI(URIEvent ev){ //might want to show tooltip immediately, //by setting initial delay to zero: ToolTipManager.sharedInstance().setInitialDelay(0); } /** * This method is called to indicate that the mouse has entered the URI. * * @param ev * Describes the URI */ void enterURI(URIEvent ev){ //TODO: First filter out those unwanted URIs. //if(ev not wanted) return; // Get current delay formerInitialDelay = ToolTipManager.sharedInstance().getInitialDelay(); // Show tool tips soon enough ToolTipManager.sharedInstance().setInitialDelay(myInitialDelay); // Get current delay formerDismissDelay = ToolTipManager.sharedInstance().getDismissDelay(); // Set delay longer enough ToolTipManager.sharedInstance().setDismissDelay(myDismissDelay); //TODO: set tooltip text (can be html) formerTip = comp.getToolTipText(); comp.setToolTipText(ev.toString()); } /** * This method is called to indicate that the mouse has left the URI. * * @param ev * Describes the URI */ void leaveURI(URIEvent ev){ //TODO: First filter out those unwanted URIs. //if(ev not wanted) return; ToolTipManager.sharedInstance().setInitialDelay(formerInitialDelay); ToolTipManager.sharedInstance().setDismissDelay(formerDismissDelay); //TODO: restore to former tooltip text comp.setToolTipText(formerTip); } }