public void setVisible(boolean visible) { if (!visible && myView != null) { disposeAndUpdate(false); } else if (visible && myView == null) { Window owner = UIUtil.getWindow(myOwner); if (owner != null) { if (myHeavyWeight) { Window view = pop(owner); if (view == null) { view = new JWindow(owner); setPopupType(view); } setAlwaysOnTop(view, myAlwaysOnTop); setWindowFocusable(view, myWindowFocusable); setWindowShadow(view, myWindowShadow); myView = view; } else if (owner instanceof RootPaneContainer) { JLayeredPane parent = ((RootPaneContainer) owner).getLayeredPane(); if (parent != null) { JPanel view = new JPanel(new BorderLayout()); view.setVisible(false); parent.add(view, JLayeredPane.POPUP_LAYER, 0); myView = view; } } } if (myView != null) { myView.add(myContent); Component parent = myView instanceof Window ? null : myView.getParent(); if (parent != null) { Point location = myViewBounds.getLocation(); SwingUtilities.convertPointFromScreen(location, parent); myViewBounds.setLocation(location); } myView.setBackground(UIUtil.getLabelBackground()); myView.setBounds(myViewBounds); myView.setVisible(true); myViewBounds = null; } } }
/** * Sets whether this popup should grab a focus. This property is used by heavy weight popups only. */ public void setWindowFocusable(boolean value) { if (myWindowFocusable != value) { myWindowFocusable = value; disposeAndUpdate(true); } }
/** * Sets whether this popup should be a separate window. A light weight popups are painted on the * layered pane. */ public void setHeavyWeight(boolean value) { if (myHeavyWeight != value) { myHeavyWeight = value; disposeAndUpdate(true); } }
/** * Sets whether this popup should be always on top. This property is used by heavy weight popups * only. */ public void setAlwaysOnTop(boolean value) { if (myAlwaysOnTop != value) { myAlwaysOnTop = value; disposeAndUpdate(true); } }
/** * Sets whether this popup should have a shadow. This property is used by heavy weight popups * only. */ public void setWindowShadow(boolean value) { if (myWindowShadow != value) { myWindowShadow = value; disposeAndUpdate(true); } }