/** Returns the popup type to use for the specified parameters. */ private int getPopupType(Component owner, Component contents, int ownerX, int ownerY) { int popupType = getPopupType(); if (owner == null || invokerInHeavyWeightPopup(owner)) { popupType = HEAVY_WEIGHT_POPUP; } else if (popupType == LIGHT_WEIGHT_POPUP && !(contents instanceof JToolTip) && !(contents instanceof JPopupMenu)) { popupType = MEDIUM_WEIGHT_POPUP; } // Check if the parent component is an option pane. If so we need to // force a heavy weight popup in order to have event dispatching work // correctly. Component c = owner; while (c != null) { if (c instanceof JComponent) { if (((JComponent) c).getClientProperty(PopupFactory_FORCE_HEAVYWEIGHT_POPUP) == Boolean.TRUE) { popupType = HEAVY_WEIGHT_POPUP; break; } } else if (c instanceof Window) { Window w = (Window) c; if (!w.isOpaque() || w.getOpacity() < 1 || w.getShape() != null) { popupType = HEAVY_WEIGHT_POPUP; break; } } c = c.getParent(); } return popupType; }
/** * Enter full-screen mode, or return to windowed mode. The entered full-screen mode may be either * exclusive or simulated. Exclusive mode is only available if <code>isFullScreenSupported</code> * returns <code>true</code>. * * <p>Exclusive mode implies: * * <ul> * <li>Windows cannot overlap the full-screen window. All other application windows will always * appear beneath the full-screen window in the Z-order. * <li>There can be only one full-screen window on a device at any time, so calling this method * while there is an existing full-screen Window will cause the existing full-screen window * to return to windowed mode. * <li>Input method windows are disabled. It is advisable to call <code> * Component.enableInputMethods(false)</code> to make a component a non-client of the input * method framework. * </ul> * * <p>Simulated full-screen mode resizes the window to the size of the screen and positions it at * (0,0). * * <p>When entering full-screen mode, if the window to be used as a full-screen window is not * visible, this method will make it visible. It will remain visible when returning to windowed * mode. * * <p>When entering full-screen mode, all the translucency effects are reset for the window. Its * shape is set to {@code null}, the opacity value is set to 1.0f, and the background color alpha * is set to 255 (completely opaque). These values are not restored when returning to windowed * mode. * * <p>When returning to windowed mode from an exclusive full-screen window, any display changes * made by calling {@code setDisplayMode} are automatically restored to their original state. * * @param w a window to use as the full-screen window; {@code null} if returning to windowed mode. * Some platforms expect the fullscreen window to be a top-level component (i.e., a {@code * Frame}); therefore it is preferable to use a {@code Frame} here rather than a {@code * Window}. * @see #isFullScreenSupported * @see #getFullScreenWindow * @see #setDisplayMode * @see Component#enableInputMethods * @see Component#setVisible * @since 1.4 */ public void setFullScreenWindow(Window w) { if (w != null) { if (w.getShape() != null) { w.setShape(null); } if (w.getOpacity() < 1.0f) { w.setOpacity(1.0f); } if (!w.isOpaque()) { Color bgColor = w.getBackground(); bgColor = new Color(bgColor.getRed(), bgColor.getGreen(), bgColor.getBlue(), 255); w.setBackground(bgColor); } } if (fullScreenWindow != null && windowedModeBounds != null) { // if the window went into fs mode before it was realized it may // have (0,0) dimensions if (windowedModeBounds.width == 0) windowedModeBounds.width = 1; if (windowedModeBounds.height == 0) windowedModeBounds.height = 1; fullScreenWindow.setBounds(windowedModeBounds); } // Set the full screen window synchronized (fsAppContextLock) { // Associate fullscreen window with current AppContext if (w == null) { fullScreenAppContext = null; } else { fullScreenAppContext = AppContext.getAppContext(); } fullScreenWindow = w; } if (fullScreenWindow != null) { windowedModeBounds = fullScreenWindow.getBounds(); // Note that we use the graphics configuration of the device, // not the window's, because we're setting the fs window for // this device. Rectangle screenBounds = getDefaultConfiguration().getBounds(); fullScreenWindow.setBounds( screenBounds.x, screenBounds.y, screenBounds.width, screenBounds.height); fullScreenWindow.setVisible(true); fullScreenWindow.toFront(); } }