Class FocusableTip


  • public class FocusableTip
    extends java.lang.Object
    A focusable tool tip, similar to those found in Eclipse. The user can click in the tip and it becomes a "real," resizable window.
    Version:
    1.0
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      private class  FocusableTip.TextAreaListener
      Listens for events in a text area.
    • Constructor Summary

      Constructors 
      Constructor Description
      FocusableTip​(javax.swing.JTextArea textArea, javax.swing.event.HyperlinkListener listener)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private void computeTipVisibleBounds()
      Compute the bounds in which the user can move the mouse without the tip window disappearing.
      private void createAndShowTipWindow​(java.awt.event.MouseEvent e, java.lang.String text)  
      java.net.URL getImageBase()
      Returns the base URL to use when loading images in this focusable tip.
      java.awt.Dimension getMaxSize()
      The maximum size for unfocused tool tips.
      (package private) static java.lang.String getString​(java.lang.String key)
      Returns localized text for the given key.
      protected void invokeLater​(java.lang.Runnable r)  
      void possiblyDisposeOfTipWindow()
      Disposes of the focusable tip currently displayed, if any.
      (package private) void removeListeners()  
      void setImageBase​(java.net.URL url)
      Sets the base URL to use when loading images in this focusable tip.
      void setMaxSize​(java.awt.Dimension maxSize)
      Sets the maximum size for unfocused tool tips.
      private void setTextArea​(javax.swing.JTextArea textArea)  
      void toolTipRequested​(java.awt.event.MouseEvent e, java.lang.String text)
      Callback called when this tool tip is requested.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • textArea

        private javax.swing.JTextArea textArea
      • imageBase

        private java.net.URL imageBase
      • hyperlinkListener

        private javax.swing.event.HyperlinkListener hyperlinkListener
      • lastText

        private java.lang.String lastText
      • maxSize

        private java.awt.Dimension maxSize
      • tipVisibleBounds

        private java.awt.Rectangle tipVisibleBounds
        The screen bounds in which the mouse has to stay for the currently displayed tip to stay visible.
      • X_MARGIN

        private static final int X_MARGIN
        Margin from mouse cursor at which to draw focusable tip.
        See Also:
        Constant Field Values
      • Y_MARGIN

        private static final int Y_MARGIN
        Margin from mouse cursor at which to draw focusable tip.
        See Also:
        Constant Field Values
      • MSG

        private static final java.util.ResourceBundle MSG
    • Constructor Detail

      • FocusableTip

        public FocusableTip​(javax.swing.JTextArea textArea,
                            javax.swing.event.HyperlinkListener listener)
    • Method Detail

      • computeTipVisibleBounds

        private void computeTipVisibleBounds()
        Compute the bounds in which the user can move the mouse without the tip window disappearing.
      • createAndShowTipWindow

        private void createAndShowTipWindow​(java.awt.event.MouseEvent e,
                                            java.lang.String text)
      • getImageBase

        public java.net.URL getImageBase()
        Returns the base URL to use when loading images in this focusable tip.
        Returns:
        The base URL to use.
        See Also:
        setImageBase(URL)
      • getMaxSize

        public java.awt.Dimension getMaxSize()
        The maximum size for unfocused tool tips.
        Returns:
        The maximum size for unfocused tool tips. A value of null will use a default size.
        See Also:
        setMaxSize(Dimension)
      • getString

        static java.lang.String getString​(java.lang.String key)
        Returns localized text for the given key.
        Parameters:
        key - The key into the resource bundle.
        Returns:
        The localized text.
      • invokeLater

        protected void invokeLater​(java.lang.Runnable r)
      • possiblyDisposeOfTipWindow

        public void possiblyDisposeOfTipWindow()
        Disposes of the focusable tip currently displayed, if any.
      • removeListeners

        void removeListeners()
      • setImageBase

        public void setImageBase​(java.net.URL url)
        Sets the base URL to use when loading images in this focusable tip.
        Parameters:
        url - The base URL to use.
        See Also:
        getImageBase()
      • setMaxSize

        public void setMaxSize​(java.awt.Dimension maxSize)
        Sets the maximum size for unfocused tool tips.
        Parameters:
        maxSize - The new maximum size. A value of null will cause a default size to be used.
        See Also:
        getMaxSize()
      • setTextArea

        private void setTextArea​(javax.swing.JTextArea textArea)
      • toolTipRequested

        public void toolTipRequested​(java.awt.event.MouseEvent e,
                                     java.lang.String text)
        Callback called when this tool tip is requested.
        Parameters:
        e - The mouse event that is triggering the tool tip.
        text - The text to display.