/[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.15 by langel, Tue Sep 20 21:11:59 2005 UTC revision 1.16 by langel, Tue Sep 20 22:00:54 2005 UTC
# Line 471  public class ToolTipManager extends Mous Line 471  public class ToolTipManager extends Mous
471          && currentComponent instanceof JComponent)          && currentComponent instanceof JComponent)
472        currentTip = ((JComponent) currentComponent).createToolTip();        currentTip = ((JComponent) currentComponent).createToolTip();
473    
474        Container parent = currentComponent.getParent();
475        if (parent instanceof JPopupMenu)
476          setLightWeightPopupEnabled(((JPopupMenu) parent).isLightWeightPopupEnabled());
477        
478      Point p = currentPoint;      Point p = currentPoint;
479      Dimension dims = currentTip.getPreferredSize();      Dimension dims = currentTip.getPreferredSize();
     if (canToolTipFit(currentTip))  
       {  
     JLayeredPane pane = ((JRootPane) SwingUtilities.  
         getAncestorOfClass(JRootPane.class, currentComponent)).getLayeredPane();  
   
     // This should never happen, but just in case.  
     if (pane == null)  
       return;  
   
     if (containerPanel != null)  
       hideTip();  
     containerPanel = new Panel();  
480      if (isLightWeightPopupEnabled())      if (isLightWeightPopupEnabled())
481        {        {
482            JLayeredPane pane = ((JRootPane) SwingUtilities.
483                getAncestorOfClass(JRootPane.class, currentComponent)).
484                getLayeredPane();
485    
486            // This should never happen, but just in case.
487            if (pane == null)
488              return;
489    
490            if (containerPanel != null)
491              hideTip();
492            containerPanel = new Panel();
493          JRootPane root = new JRootPane();          JRootPane root = new JRootPane();
494          root.getContentPane().add(currentTip);          root.getContentPane().add(currentTip);
495          containerPanel.add(root);          containerPanel.add(root);
       }  
     else  
         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);  
496    
497      pane.revalidate();          LayoutManager lm = containerPanel.getLayout();
498      pane.repaint();          if (lm instanceof FlowLayout)
499              {
500                FlowLayout fm = (FlowLayout) lm;
501                fm.setVgap(0);
502                fm.setHgap(0);
503              }
504    
505            p = getGoodPoint(currentPoint, pane, currentTip, dims);
506            pane.add(containerPanel);
507            containerPanel.setBounds(p.x, p.y, dims.width, dims.height);
508            currentTip.setBounds(0, 0, dims.width, dims.height);
509            pane.revalidate();
510            pane.repaint();
511        }        }
512      else if (currentComponent.isShowing())      else if (currentComponent.isShowing())
513        {        {
# Line 515  public class ToolTipManager extends Mous Line 515  public class ToolTipManager extends Mous
515          tooltipWindow = new JDialog();          tooltipWindow = new JDialog();
516          tooltipWindow.setContentPane(currentTip);          tooltipWindow.setContentPane(currentTip);
517          tooltipWindow.setUndecorated(true);          tooltipWindow.setUndecorated(true);
518          tooltipWindow.getRootPane().setWindowDecorationStyle(JRootPane.PLAIN_DIALOG);          tooltipWindow.getRootPane().
519          tooltipWindow.setFocusable(false);                  setWindowDecorationStyle(JRootPane.PLAIN_DIALOG);
520          tooltipWindow.pack();          tooltipWindow.pack();
521          tooltipWindow.setBounds(p.x, p.y, dims.width, dims.height);          tooltipWindow.setBounds(p.x, p.y, dims.width, dims.height);
522          tooltipWindow.show();          tooltipWindow.show();
523        }        }
524      currentTip.setVisible(true);      currentTip.setVisible(true);
525        currentTip.revalidate();
526        currentTip.repaint();
527    }    }
528    
529    /**    /**
# Line 609  public class ToolTipManager extends Mous Line 611  public class ToolTipManager extends Mous
611      Component target = SwingUtilities.getDeepestComponentAt(parent, p.x, p.y);      Component target = SwingUtilities.getDeepestComponentAt(parent, p.x, p.y);
612      return target;      return target;
613    }    }
   
   /**  
    * This method returns whether the ToolTip can fit in the first  
    * RootPaneContainer up from the currentComponent.  
    *  
    * @param tip The ToolTip.  
    *  
    * @return Whether the ToolTip can fit.  
    */  
   private boolean canToolTipFit(JToolTip tip)  
   {  
     JRootPane root = (JRootPane) SwingUtilities.getAncestorOfClass(JRootPane.class,  
                                                                    currentComponent);  
     if (root == null)  
       return false;  
     Dimension pref = tip.getPreferredSize();  
     Dimension rootSize = root.getSize();  
     if (rootSize.width > pref.width && rootSize.height > pref.height)  
       return true;  
     return false;  
   }  
614  }  }

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

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