private void showTooltip ( ) { Wrap tooltipLabel = new Wrap ( toolTipWrapWidth ) ; tooltipLabel . setForeground ( getForeground ( ) ) ; tooltipLabel . setFont ( ToolTipButton . this . getFont ( ) ) ; tooltipLabel . setText ( text ) ; JPanel panel = new JPanel ( ) ; panel . setBackground ( toolTipBackground ) ; panel . setLayout ( new BorderLayout ( ) ) ; panel . add ( tooltipLabel , BorderLayout . CENTER ) ; if ( extraComponent != null && extraComponentAnchor != null ) { if ( extraComponentAnchor . equals ( ToolTipButtonAnchor . SOUTH ) ) { panel . add ( extraComponent , BorderLayout . SOUTH ) ; } else if ( extraComponentAnchor . equals ( ToolTipButtonAnchor . NORTH ) ) { panel . add ( extraComponent , BorderLayout . NORTH ) ; } else if ( extraComponentAnchor . equals ( ToolTipButtonAnchor . EAST ) ) { panel . add ( extraComponent , BorderLayout . EAST ) ; } else if ( extraComponentAnchor . equals ( ToolTipButtonAnchor . WEST ) ) { panel . add ( extraComponent , BorderLayout . WEST ) ; } } Border out = BorderFactory . createLineBorder ( borderColor , borderThickness ) ; Border in = BorderFactory . createEmptyBorder ( margin . top , margin . left , margin . bottom , margin . right ) ; Border border = BorderFactory . createCompoundBorder ( out , in ) ; panel . setBorder ( border ) ; popup = new JPopupMenu ( ) ; popup . setBorder ( BorderFactory . createEmptyBorder ( ) ) ; popup . add ( panel ) ; popup . addMouseListener ( new MouseAdapter ( ) { @ Override public void mouseExited ( MouseEvent e ) { tryDisposeTooltip ( ) ; } } ) ; popup . pack ( ) ; popup . show ( ToolTipButton . this , 0 , getHeight ( ) ) ; Point point = popup . getLocationOnScreen ( ) ; Dimension dim = popup . getSize ( ) ; popupBounds = new Rectangle2D . Double ( point . getX ( ) , point . getY ( ) , dim . getWidth ( ) , dim . getHeight ( ) ) ; }
Show the tooltip .