2005-09-20  Lillian Angel  <[EMAIL PROTECTED]>

        * javax/swing/ToolTipManager.java
        (mouseMoved): Removed unneeded code. If the mouse
        moves into another component, then mouseEntered would
        do the same thing. Otherwise, it is not needed.
        (showTip): Fixed so that the containerPanel is an
        instance of Panel. Made code more efficent.
        Tooltips were causing weird problems with the
        JMenus.
        (getGoodPoint): Fixed to return a better location.
        * javax/swing/plaf/basic/BasicMenuBarUI.java
        (mouseClicked): Fixed to prevent a NPE.

Index: javax/swing/ToolTipManager.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/ToolTipManager.java,v
retrieving revision 1.14
diff -u -r1.14 ToolTipManager.java
--- javax/swing/ToolTipManager.java	19 Sep 2005 19:42:22 -0000	1.14
+++ javax/swing/ToolTipManager.java	20 Sep 2005 21:06:36 -0000
@@ -452,16 +452,8 @@
   public void mouseMoved(MouseEvent event)
   {
     currentPoint = event.getPoint();
-    if (currentTip != null)
-      {
-	if (currentComponent == null)
-	  currentComponent = (Component) event.getSource();
-	
-	String text = ((JComponent) currentComponent).getToolTipText(event);
-	currentTip.setTipText(text);
-      }
     if (enterTimer.isRunning())
-      enterTimer.restart();
+      enterTimer.restart(); 
   }
 
   /**
@@ -471,73 +463,63 @@
    */
   void showTip()
   {
-    if (! enabled || currentComponent == null ||
-        (currentTip != null && currentTip.isVisible()))
+    if (!enabled || currentComponent == null
+        || (currentTip != null && currentTip.isVisible()))
       return;
 
-    if (currentTip == null
-        || currentTip.getComponent() != currentComponent
+    if (currentTip == null || currentTip.getComponent() != currentComponent
         && currentComponent instanceof JComponent)
       currentTip = ((JComponent) currentComponent).createToolTip();
-   
+
     Point p = currentPoint;
     Dimension dims = currentTip.getPreferredSize();
     if (canToolTipFit(currentTip))
       {
-	JLayeredPane pane = ((JRootPane) SwingUtilities.getAncestorOfClass(JRootPane.class,
-	                                                                   currentComponent))
-	                    .getLayeredPane();
+    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();
-	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);
+    // This should never happen, but just in case.
+    if (pane == null)
+      return;
 
-	pane.revalidate();
-	pane.repaint();
+    if (containerPanel != null)
+      hideTip();
+    containerPanel = new Panel();
+    if (isLightWeightPopupEnabled())
+      {
+        JRootPane root = new JRootPane();
+        root.getContentPane().add(currentTip);
+        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);
+
+    pane.revalidate();
+    pane.repaint();
+      }
+    else if (currentComponent.isShowing())
       {
-        if (currentComponent.isShowing())
-          {
-            SwingUtilities.convertPointToScreen(p, currentComponent);
-            tooltipWindow = new JDialog();
-            tooltipWindow.getContentPane().add(currentTip);
-            tooltipWindow.setUndecorated(true);
-            tooltipWindow.getRootPane().
-                      setWindowDecorationStyle(JRootPane.PLAIN_DIALOG);
-            tooltipWindow.setFocusable(false);
-            tooltipWindow.pack();
-            tooltipWindow.setBounds(p.x, p.y, dims.width, dims.height);
-            tooltipWindow.show();
-          }
+        SwingUtilities.convertPointToScreen(p, currentComponent);
+        tooltipWindow = new JDialog();
+        tooltipWindow.setContentPane(currentTip);
+        tooltipWindow.setUndecorated(true);
+        tooltipWindow.getRootPane().setWindowDecorationStyle(JRootPane.PLAIN_DIALOG);
+        tooltipWindow.setFocusable(false);
+        tooltipWindow.pack();
+        tooltipWindow.setBounds(p.x, p.y, dims.width, dims.height);
+        tooltipWindow.show();
       }
     currentTip.setVisible(true);
   }
@@ -597,9 +579,9 @@
       dims = tip.getPreferredSize();
     Rectangle bounds = currentComponent.getBounds();
     if (p.x + dims.width > bounds.width)
-      p.x = bounds.width - dims.width;
+      p.x += bounds.width - dims.width;
     if (p.y + dims.height > bounds.height)
-      p.y = bounds.height - dims.height;
+      p.y += bounds.height;
 
     p = SwingUtilities.convertPoint(currentComponent, p, c);
     return p;
Index: javax/swing/plaf/basic/BasicMenuBarUI.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/basic/BasicMenuBarUI.java,v
retrieving revision 1.11
diff -u -r1.11 BasicMenuBarUI.java
--- javax/swing/plaf/basic/BasicMenuBarUI.java	6 Sep 2005 18:46:03 -0000	1.11
+++ javax/swing/plaf/basic/BasicMenuBarUI.java	20 Sep 2005 21:06:36 -0000
@@ -50,6 +50,7 @@
 
 import javax.swing.BoxLayout;
 import javax.swing.JComponent;
+import javax.swing.JMenu;
 import javax.swing.JMenuBar;
 import javax.swing.MenuElement;
 import javax.swing.UIDefaults;
@@ -326,7 +327,11 @@
       MenuElement[] me = menuBar.getSubElements();
       
       for (int i = 0; i < me.length; i++)
-        menuBar.getMenu(i).setSelected(false);
+        {
+          JMenu menu = menuBar.getMenu(i);
+          if (menu != null)
+            menu.setSelected(false);
+        }
_______________________________________________
Classpath-patches mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/classpath-patches

Reply via email to