2362N/A * Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 2362N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 2362N/A * by Oracle in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2362N/A * or visit www.oracle.com if you need additional information or have any 0N/A * <code>PopupFactory</code>, as the name implies, is used to obtain 0N/A * instances of <code>Popup</code>s. <code>Popup</code>s are used to 0N/A * display a <code>Component</code> above all other <code>Component</code>s 0N/A * in a particular containment hierarchy. The general contract is that 0N/A * once you have obtained a <code>Popup</code> from a 0N/A * <code>PopupFactory</code>, you must invoke <code>hide</code> on the 0N/A * <code>Popup</code>. The typical usage is: 0N/A * PopupFactory factory = PopupFactory.getSharedInstance(); 0N/A * Popup popup = factory.getPopup(owner, contents, x, y); 0N/A * The shared instanceof <code>PopupFactory</code> is per 0N/A * <code>AppContext</code>. This is the key used in the 0N/A * <code>AppContext</code> to locate the <code>PopupFactory</code>. 0N/A * Max number of items to store in any one particular cache. 0N/A * Key used to indicate a light weight popup should be used. 0N/A * Key used to indicate a medium weight Popup should be used. 0N/A * Key used to indicate a heavy weight Popup should be used. 0N/A * Default type of Popup to create. 0N/A * Sets the <code>PopupFactory</code> that will be used to obtain 0N/A * <code>Popup</code>s. 0N/A * This will throw an <code>IllegalArgumentException</code> if 0N/A * <code>factory</code> is null. 0N/A * @param factory Shared PopupFactory 0N/A * @exception IllegalArgumentException if <code>factory</code> is null 0N/A * Returns the shared <code>PopupFactory</code> which can be used 0N/A * to obtain <code>Popup</code>s. 0N/A * @return Shared PopupFactory 0N/A * Provides a hint as to the type of <code>Popup</code> that should 0N/A * Returns the preferred type of Popup to create. 0N/A * Creates a <code>Popup</code> for the Component <code>owner</code> 0N/A * containing the Component <code>contents</code>. <code>owner</code> 0N/A * is used to determine which <code>Window</code> the new 0N/A * <code>Popup</code> will parent the <code>Component</code> the 0N/A * <code>Popup</code> creates to. A null <code>owner</code> implies there 0N/A * is no valid parent. <code>x</code> and 0N/A * <code>y</code> specify the preferred initial location to place 0N/A * the <code>Popup</code> at. Based on screen size, or other paramaters, 0N/A * the <code>Popup</code> may not display at <code>x</code> and 0N/A * @param owner Component mouse coordinates are relative to, may be null 0N/A * @param contents Contents of the Popup 0N/A * @param x Initial x screen coordinate 0N/A * @param y Initial y screen coordinate 0N/A * @exception IllegalArgumentException if contents is null 0N/A * @return Popup containing Contents 0N/A "Popup.getPopup must be passed non-null contents");
0N/A // Didn't fit, force to heavy. 0N/A * Returns the popup type to use for the specified parameters. 0N/A // Check if the parent component is an option pane. If so we need to 0N/A // force a heavy weight popup in order to have event dispatching work 0N/A * Obtains the appropriate <code>Popup</code> based on 0N/A * <code>popupType</code>. 0N/A * Creates a headless popup 0N/A * Creates a light weight popup. 0N/A * Creates a medium weight popup. 0N/A * Creates a heavy weight popup. 0N/A * Returns true if the Component <code>i</code> inside a heavy weight 0N/A * <code>Popup</code>. 0N/A * Popup implementation that uses a Window as the popup. 0N/A * Returns either a new or recycled <code>Popup</code> containing 0N/A * the specified children. 0N/A // The recycled popup can't serve us well 0N/A // dispose it and create new one 0N/A // Set window name. We need this in BasicPopupMenuUI 0N/A // to identify focusable popup window. 0N/A * Returns a previously disposed heavy weight <code>Popup</code> 0N/A * associated with <code>window</code>. This will return null if 0N/A * there is no <code>HeavyWeightPopup</code> associated with 0N/A * <code>window</code>. 0N/A * Returns the cache to use for heavy weight popups. Maps from 0N/A * <code>Window</code> to a <code>List</code> of 0N/A * <code>HeavyWeightPopup</code>s. 0N/A * Recycles the passed in <code>HeavyWeightPopup</code>. 0N/A // If the Window isn't visible, we don't cache it as we 0N/A // likely won't ever get a windowClosed event to clean up. 0N/A // We also don't cache DefaultFrames as this indicates 0N/A // there wasn't a valid Window parent, and thus we don't 0N/A // know when to clean up. 0N/A // Clean up if the Window is closed 0N/A * As we recycle the <code>Window</code>, we don't want to dispose it, 0N/A * thus this method does nothing, instead use <code>_dipose</code> 0N/A * which will handle the disposing. 0N/A * ContainerPopup consolidates the common code used in the light/medium 0N/A * weight implementations of <code>Popup</code>. 0N/A /** Component we are to be added to. */ 0N/A /** Desired x location. */ 0N/A /** Desired y location. */ 0N/A // Force the content to be added to the layered pane, otherwise 0N/A // we'll get an exception when adding to the RootPaneContainer. 341N/A * Returns true if popup can fit the screen and the owner's top parent. 341N/A * It determines can popup be lightweight or mediumweight. 0N/A // If we have GraphicsConfiguration use it 0N/A // to get screen bounds 0N/A // If we don't have GraphicsConfiguration use primary screen 0N/A // Take insets into account 0N/A * Popup implementation that is used in headless environment. 0N/A * Popup implementation that uses a JPanel as the popup. 0N/A * Returns a light weight <code>Popup</code> implementation. If 0N/A * the <code>Popup</code> needs more space that in available in 0N/A * <code>owner</code>, this will return null. 0N/A * Returns the cache to use for heavy weight popups. 0N/A * Recycles the LightWeightPopup <code>popup</code>. 0N/A * Returns a previously used <code>LightWeightPopup</code>, or null 0N/A * if none of the popups have been recycled. 0N/A // Try to find a JLayeredPane and Window to add 0N/A // Continue, so that if there is a higher JRootPane, we'll 0N/A // Painting code stops at Applets, we don't want 0N/A // to add to a Component above an Applet otherwise 0N/A // you'll never see it painted. 0N/A * Resets the <code>Popup</code> to an initial state. 0N/A * Popup implementation that uses a Panel as the popup. 0N/A /** Child of the panel. The contents are added to this. */ 0N/A * Returns a medium weight <code>Popup</code> implementation. If 0N/A * the <code>Popup</code> needs more space that in available in 0N/A * <code>owner</code>, this will return null. 0N/A * Returns the cache to use for medium weight popups. 0N/A * Recycles the MediumWeightPopup <code>popup</code>. 0N/A * Returns a previously used <code>MediumWeightPopup</code>, or null 0N/A * if none of the popups have been recycled. 0N/A Find the top level window, 0N/A if it has a layered pane, 0N/A add to that, otherwise 0N/A add to the window. */ 0N/A // Set the visibility to false before adding to workaround a 0N/A // bug in Solaris in which the Popup gets added at the wrong 0N/A // location, which will result in a mouseExit, which will then 0N/A // result in the ToolTip being removed. 0N/A // NOTE: this uses setOpaque vs LookAndFeel.installProperty as 0N/A // there is NO reason for the RootPane not to be opaque. For 0N/A // painting to work the contentPane must be opaque, therefor the 0N/A // RootPane can also be opaque. 0N/A * Resets the <code>Popup</code> to an initial state. 0N/A // This implements SwingHeavyWeight so that repaints on it 0N/A // are processed by the RepaintManager and SwingPaintEventDispatcher.