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

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

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

revision 1.1.2.1 by gnu_andrew, Tue Aug 2 20:12:37 2005 UTC revision 1.1.2.2 by gnu_andrew, Wed Nov 2 00:43:48 2005 UTC
# Line 39  exception statement from your version. * Line 39  exception statement from your version. *
39  package javax.swing;  package javax.swing;
40    
41  import java.awt.Component;  import java.awt.Component;
42    import java.awt.Dimension;
43    import java.awt.Point;
44    
45    
46  /**  /**
# Line 55  public class PopupFactory Line 57  public class PopupFactory
57    /**    /**
58     * The shared factory object.     * The shared factory object.
59     *     *
60     * @see #getSharedFactory     * @see #getSharedInstance
61     * @see #setSharedFactory     * @see #setSharedInstance
62     */     */
63    private static PopupFactory sharedFactory;    private static PopupFactory sharedFactory;
64    
# Line 69  public class PopupFactory Line 71  public class PopupFactory
71     */     */
72    public PopupFactory()    public PopupFactory()
73    {    {
74        // Nothing to do here.
75    }    }
76    
77    
# Line 134  public class PopupFactory Line 137  public class PopupFactory
137    public Popup getPopup(Component owner, Component contents,    public Popup getPopup(Component owner, Component contents,
138                          int x, int y)                          int x, int y)
139    {    {
140      return new Popup.JWindowPopup(owner, contents, x, y);      Popup popup = null;
141        // By default we enable lightweight popups since they are more efficient
142        // than heavyweight popups.
143        boolean lightweightEnabled = true;
144        // Special case JPopupMenu here, since it supports a lightweightEnabled
145        // flag that we must respect.
146        if (contents instanceof JPopupMenu)
147          {
148            JPopupMenu menu = (JPopupMenu) contents;
149            lightweightEnabled = menu.isLightWeightPopupEnabled();
150          }
151    
152        // If we have a root pane and the contents fits within the root pane and
153        // lightweight popups are enabled, than we can use a lightweight popup.
154        JRootPane root = SwingUtilities.getRootPane(owner);
155        Point rootLoc = root.getLocationOnScreen();
156        Dimension contentsSize = contents.getSize();
157        Dimension rootSize = root.getSize();
158        if (x >= rootLoc.x && y > rootLoc.y
159            && (x - rootLoc.x) + contentsSize.width < rootSize.width
160            && (y - rootLoc.y) + contentsSize.height < rootSize.height)
161          popup = new Popup.LightweightPopup(owner, contents, x, y);
162        else
163          popup = new Popup.JWindowPopup(owner, contents, x, y);
164        return popup;
165    }    }
166  }  }

Legend:
Removed from v.1.1.2.1  
changed lines
  Added in v.1.1.2.2

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