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

        * javax/swing/JPopupMenu.java
        (setVisible): If HeavyWeightPopup, setLightWeightPopupEnabled
        is false.
        * javax/swing/ToolTipManager.java
        (showTip): Change so toolTips on lightWeightPopups are
        added different than those on heavyWeightPopups.
        (canToolTipFit): Removed. This is not needed/used.

Index: javax/swing/JPopupMenu.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/JPopupMenu.java,v
retrieving revision 1.22
diff -u -r1.22 JPopupMenu.java
--- javax/swing/JPopupMenu.java	12 Sep 2005 16:17:14 -0000	1.22
+++ javax/swing/JPopupMenu.java	20 Sep 2005 21:55:21 -0000
@@ -582,7 +582,10 @@
                 if (fit)
                   popup = new MediumWeightPopup(this);
                 else
-                  popup = new HeavyWeightPopup(this);
+                  {
+                    popup = new HeavyWeightPopup(this);
+                    setLightWeightPopupEnabled(false);
+                  }
               }
             if (popup instanceof LightWeightPopup
                 || popup instanceof MediumWeightPopup)
Index: javax/swing/ToolTipManager.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/ToolTipManager.java,v
retrieving revision 1.15
diff -u -r1.15 ToolTipManager.java
--- javax/swing/ToolTipManager.java	20 Sep 2005 21:11:59 -0000	1.15
+++ javax/swing/ToolTipManager.java	20 Sep 2005 21:55:21 -0000
@@ -471,43 +471,43 @@
         && currentComponent instanceof JComponent)
       currentTip = ((JComponent) currentComponent).createToolTip();
 
+    Container parent = currentComponent.getParent();
+    if (parent instanceof JPopupMenu)
+      setLightWeightPopupEnabled(((JPopupMenu) parent).isLightWeightPopupEnabled());
+    
     Point p = currentPoint;
     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();
     if (isLightWeightPopupEnabled())
       {
+        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();
         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();
+        LayoutManager lm = containerPanel.getLayout();
+        if (lm instanceof FlowLayout)
+          {
+            FlowLayout fm = (FlowLayout) lm;
+            fm.setVgap(0);
+            fm.setHgap(0);
+          }
+
+        p = getGoodPoint(currentPoint, 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())
       {
@@ -515,13 +515,15 @@
         tooltipWindow = new JDialog();
         tooltipWindow.setContentPane(currentTip);
         tooltipWindow.setUndecorated(true);
-        tooltipWindow.getRootPane().setWindowDecorationStyle(JRootPane.PLAIN_DIALOG);
-        tooltipWindow.setFocusable(false);
+        tooltipWindow.getRootPane().
+                setWindowDecorationStyle(JRootPane.PLAIN_DIALOG);
         tooltipWindow.pack();
         tooltipWindow.setBounds(p.x, p.y, dims.width, dims.height);
         tooltipWindow.show();
       }
     currentTip.setVisible(true);
+    currentTip.revalidate();
+    currentTip.repaint();
   }
 
   /**
@@ -608,26 +610,5 @@
     p = SwingUtilities.convertPoint(source, p, parent);
     Component target = SwingUtilities.getDeepestComponentAt(parent, p.x, p.y);
     return target;
-  }
-
-  /**
-   * 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;
   }
 }
_______________________________________________
Classpath-patches mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/classpath-patches

Reply via email to