/[classpath]/classpath/javax/swing/ToolTipManager.java
ViewVC logotype

Diff of /classpath/javax/swing/ToolTipManager.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.14 by langel, Mon Sep 19 19:42:22 2005 UTC revision 1.15 by langel, Tue Sep 20 21:11:59 2005 UTC
# Line 452  public class ToolTipManager extends Mous Line 452  public class ToolTipManager extends Mous
452    public void mouseMoved(MouseEvent event)    public void mouseMoved(MouseEvent event)
453    {    {
454      currentPoint = event.getPoint();      currentPoint = event.getPoint();
     if (currentTip != null)  
       {  
         if (currentComponent == null)  
           currentComponent = (Component) event.getSource();  
           
         String text = ((JComponent) currentComponent).getToolTipText(event);  
         currentTip.setTipText(text);  
       }  
455      if (enterTimer.isRunning())      if (enterTimer.isRunning())
456        enterTimer.restart();        enterTimer.restart();
457    }    }
458    
459    /**    /**
# Line 471  public class ToolTipManager extends Mous Line 463  public class ToolTipManager extends Mous
463     */     */
464    void showTip()    void showTip()
465    {    {
466      if (! enabled || currentComponent == null ||      if (!enabled || currentComponent == null
467          (currentTip != null && currentTip.isVisible()))          || (currentTip != null && currentTip.isVisible()))
468        return;        return;
469    
470      if (currentTip == null      if (currentTip == null || currentTip.getComponent() != currentComponent
         || currentTip.getComponent() != currentComponent  
471          && currentComponent instanceof JComponent)          && currentComponent instanceof JComponent)
472        currentTip = ((JComponent) currentComponent).createToolTip();        currentTip = ((JComponent) currentComponent).createToolTip();
473      
474      Point p = currentPoint;      Point p = currentPoint;
475      Dimension dims = currentTip.getPreferredSize();      Dimension dims = currentTip.getPreferredSize();
476      if (canToolTipFit(currentTip))      if (canToolTipFit(currentTip))
477        {        {
478          JLayeredPane pane = ((JRootPane) SwingUtilities.getAncestorOfClass(JRootPane.class,      JLayeredPane pane = ((JRootPane) SwingUtilities.
479                                                                             currentComponent))          getAncestorOfClass(JRootPane.class, currentComponent)).getLayeredPane();
                             .getLayeredPane();  
480    
481          // This should never happen, but just in case.      // This should never happen, but just in case.
482          if (pane == null)      if (pane == null)
483            return;        return;
   
         if (containerPanel != null)  
           hideTip();  
         if (isLightWeightPopupEnabled())  
           {  
             containerPanel = new Panel();  
             JRootPane root = new JRootPane();  
             root.getContentPane().add(currentTip);  
             containerPanel.add(root);  
           }  
         else  
           {  
             containerPanel = new JPanel();  
             containerPanel.add(currentTip);  
           }  
         LayoutManager lm = containerPanel.getLayout();  
         if (lm instanceof FlowLayout)  
           {  
             FlowLayout fm = (FlowLayout) lm;  
             fm.setVgap(0);  
             fm.setHgap(0);  
           }  
   
         p = getGoodPoint(p, pane, currentTip, dims);  
   
         pane.add(containerPanel);  
         containerPanel.setBounds(p.x, p.y, dims.width, dims.height);  
         currentTip.setBounds(0, 0, dims.width, dims.height);  
484    
485          pane.revalidate();      if (containerPanel != null)
486          pane.repaint();        hideTip();
487        containerPanel = new Panel();
488        if (isLightWeightPopupEnabled())
489          {
490            JRootPane root = new JRootPane();
491            root.getContentPane().add(currentTip);
492            containerPanel.add(root);
493        }        }
494      else      else
495            containerPanel.add(currentTip);
496    
497        LayoutManager lm = containerPanel.getLayout();
498        if (lm instanceof FlowLayout)
499          {
500            FlowLayout fm = (FlowLayout) lm;
501            fm.setVgap(0);
502            fm.setHgap(0);
503          }
504        p = getGoodPoint(p, pane, currentTip, dims);
505        pane.add(containerPanel);
506        containerPanel.setBounds(p.x, p.y, dims.width, dims.height);
507        currentTip.setBounds(0, 0, dims.width, dims.height);
508    
509        pane.revalidate();
510        pane.repaint();
511          }
512        else if (currentComponent.isShowing())
513        {        {
514          if (currentComponent.isShowing())          SwingUtilities.convertPointToScreen(p, currentComponent);
515            {          tooltipWindow = new JDialog();
516              SwingUtilities.convertPointToScreen(p, currentComponent);          tooltipWindow.setContentPane(currentTip);
517              tooltipWindow = new JDialog();          tooltipWindow.setUndecorated(true);
518              tooltipWindow.getContentPane().add(currentTip);          tooltipWindow.getRootPane().setWindowDecorationStyle(JRootPane.PLAIN_DIALOG);
519              tooltipWindow.setUndecorated(true);          tooltipWindow.setFocusable(false);
520              tooltipWindow.getRootPane().          tooltipWindow.pack();
521                        setWindowDecorationStyle(JRootPane.PLAIN_DIALOG);          tooltipWindow.setBounds(p.x, p.y, dims.width, dims.height);
522              tooltipWindow.setFocusable(false);          tooltipWindow.show();
             tooltipWindow.pack();  
             tooltipWindow.setBounds(p.x, p.y, dims.width, dims.height);  
             tooltipWindow.show();  
           }  
523        }        }
524      currentTip.setVisible(true);      currentTip.setVisible(true);
525    }    }
# Line 597  public class ToolTipManager extends Mous Line 579  public class ToolTipManager extends Mous
579        dims = tip.getPreferredSize();        dims = tip.getPreferredSize();
580      Rectangle bounds = currentComponent.getBounds();      Rectangle bounds = currentComponent.getBounds();
581      if (p.x + dims.width > bounds.width)      if (p.x + dims.width > bounds.width)
582        p.x = bounds.width - dims.width;        p.x += bounds.width - dims.width;
583      if (p.y + dims.height > bounds.height)      if (p.y + dims.height > bounds.height)
584        p.y = bounds.height - dims.height;        p.y += bounds.height;
585    
586      p = SwingUtilities.convertPoint(currentComponent, p, c);      p = SwingUtilities.convertPoint(currentComponent, p, c);
587      return p;      return p;

Legend:
Removed from v.1.14  
changed lines
  Added in v.1.15

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26