/[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.3 by rabbit78, Wed Oct 19 15:45:05 2005 UTC revision 1.4 by rabbit78, Tue Oct 25 13:49:47 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 135  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.3  
changed lines
  Added in v.1.4

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