Java 类javax.swing.RootPaneContainer 实例源码

项目:incubator-netbeans    文件:ZOrderManager.java   
/** Stops to track given window (RootPaneContainer).
 */
public boolean detachWindow (RootPaneContainer rpc) {
    logger.entering(getClass().getName(), "detachWindow");

    if (!(rpc instanceof Window)) {
        throw new IllegalArgumentException("Argument must be subclas of java.awt.Window: " + rpc);   //NOI18N
    }

    WeakReference<RootPaneContainer> ww = getWeak(rpc);
    if (ww == null) {
        return false;
    }

    ((Window)rpc).removeWindowListener(this);
    return zOrder.remove(ww);
}
项目:incubator-netbeans    文件:FileChooserBuilderTest.java   
private static AbstractButton findDefaultButton(Container c, String txt) {
    if (c instanceof RootPaneContainer) {
        JRootPane root = ((RootPaneContainer) c).getRootPane();
        if (root == null) {
            return null;
        }
        AbstractButton btn = root.getDefaultButton();
        if (btn == null) {
            //Metal L&F does not set default button for JFileChooser
            Container parent = c;
            while (parent.getParent() != null && !(parent instanceof Dialog)) {
                parent = parent.getParent();
            }
            if (parent instanceof Dialog) {
                return findFileChooserAcceptButton ((Dialog) parent, txt);
            }
        } else {
            return btn;
        }
    }
    return null;
}
项目:swingspy    文件:SwingSpy.java   
/**
 * Shows spy dialog or reload existing one.
 *
 * @param rootComponent root component
 * @param component current component
 */
public void showSpyDialog(final Component rootComponent, final Component component) {
    if (spyDialog != null) {
        spyDialog.setVisible(true);
        spyGlass.setVisible(true);
        spyPanel.reload(rootComponent, component);
        return;
    }
    if (rootComponent instanceof RootPaneContainer) {
        RootPaneContainer rootPane = (RootPaneContainer) rootComponent;
        spyGlass = new SwingSpyGlassPane(rootPane);
        rootPane.setGlassPane(spyGlass);
        rootPane.getGlassPane().setVisible(true);
        Toolkit.getDefaultToolkit().addAWTEventListener(spyGlass, AWTEvent.MOUSE_MOTION_EVENT_MASK | AWTEvent.MOUSE_EVENT_MASK);
    }

    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            initSpyDialog(rootComponent, component);
        }
    });
}
项目:Equella    文件:GlassPaneUtils.java   
private static RootPaneContainer getRootContainer(Component startComponent)
{
    Component aComponent = startComponent;

    // Climb the component hierarchy until a RootPaneContainer is found or
    // until the very top
    while( (aComponent.getParent() != null) && !(aComponent instanceof RootPaneContainer) )
    {
        aComponent = aComponent.getParent();
    }

    // Guard against error conditions if climb search wasn't successful
    if( aComponent instanceof RootPaneContainer )
    {
        return (RootPaneContainer) aComponent;
    }

    return null;
}
项目:hiervis    文件:SwingUIUtils.java   
/**
 * {@linkplain #installOperation(RootPaneContainer, int, KeyStroke, String, Action)}
 */
public static Action installOperation(
    final RootPaneContainer frame,
    final int condition,
    final KeyStroke keyStroke,
    final String actionKey,
    final Runnable runnable )
{
    Action result = new AbstractAction( actionKey ) {
        public void actionPerformed( ActionEvent e )
        {
            runnable.run();
        }
    };

    installOperation( frame, condition, keyStroke, actionKey, result );
    return result;
}
项目:hiervis    文件:SwingUIUtils.java   
/**
 * Removes an operation installed in the specified frame for the specified
 * keystroke and condition.
 * 
 * @param frame
 *            The frame from which the keybind is to be uninstalled.
 * @param condition
 *            When should this keybind be activated.
 *            Either {@link JComponent#WHEN_FOCUSED}, {@link JComponent#WHEN_IN_FOCUSED_WINDOW}, or
 *            {@link JComponent#WHEN_ANCESTOR_OF_FOCUSED_COMPONENT}.
 * @param keyStroke
 *            The keystroke used to activate the keybind
 */
public static void uninstallOperation(
    final RootPaneContainer frame,
    final int condition,
    final KeyStroke keyStroke )
{
    JRootPane root = frame.getRootPane();

    InputMap inputMap = root.getInputMap( condition );
    InputMap parentMap = inputMap.getParent();

    // Temporarily remove the parent input map, so that we don't receive the
    // action key from the parent's input map if the current input map has
    // no action key bound to the key stroke.
    inputMap.setParent( null );

    Object actionKey = root.getInputMap( condition ).get( keyStroke );
    if ( actionKey == null )
        throw new OperationNotInstalledException( keyStroke );
    root.getInputMap( condition ).remove( keyStroke );
    root.getActionMap().remove( actionKey );

    inputMap.setParent( parentMap );
}
项目:hiervis    文件:SwingUIUtils.java   
/**
 * Returns the Action installed under the specified action key in the specified frame.
 * 
 * @param frame
 *            The frame in which the action is installed
 * @param actionKey
 *            The action key to which the action is bound
 * @param selfOnly
 *            If true, will only check the frame specified in argument for actions bound
 *            to the action key.
 *            If false, will check any parents of the action map for actions bound to the
 *            action key, if none was found in the first one.
 */
public static Action getInstalledOperation(
    final RootPaneContainer frame,
    final Object actionKey,
    boolean selfOnly )
{
    JRootPane root = frame.getRootPane();

    if ( selfOnly ) {
        ActionMap actionMap = root.getActionMap();
        ActionMap parentMap = actionMap.getParent();

        actionMap.setParent( null );
        Action result = actionMap.get( actionKey );
        actionMap.setParent( parentMap );

        return result;
    }
    else {
        return root.getActionMap().get( actionKey );
    }
}
项目:jGAF    文件:DesignGridLayout.java   
/**
 * Builds a DesignGridLayout instance attached to a {@link Container}.
 * This instance should be then used to add rows and components to the parent
 * container.
 * <p/>
 * Note that this constructor auomatically calls {@code parent.setLayout(this)}
 * so you don't need to call it yourself.
 * <p/>
 * In no way should the {@link Container#add} and {@link Container#remove}
 * ever be used with {@code parent}.
 * 
 * @param parent the container for which we want to use DesignGridLayout; 
 * cannot be {@code null}.
 */
public DesignGridLayout(Container parent)
{
    if (parent == null)
    {
        throw new NullPointerException("parent cannot be null");
    }
    Container target = parent;
    if (parent instanceof RootPaneContainer)
    {
        target = ((RootPaneContainer) parent).getContentPane();
    }
    _wrapper = new ParentWrapper<Container>(target);
    _orientation = new OrientationPolicy(target);
    _layout = new DesignGridLayoutManager(this, _wrapper, _rows, _orientation);
    _layout.setHeightTester(_heightTester);
    target.setLayout(_layout);
}
项目:pumpernickel    文件:LocationPaneUI.java   
/** Turn on/off special shortcuts. For example: on Mac command+D should navigate to the desktop.
 */
protected void setShortcutsActive(boolean b) {
    Window window = SwingUtilities.getWindowAncestor(locationPane);
    /** T4L Bug 21770 had to do with a normally hidden LocationPaneUI consuming cmd+D
     * keystrokes. So now we only install these keystrokes if we're visible and
     * in a dialog...
     */
    if(window instanceof RootPaneContainer && window instanceof Dialog) {
        RootPaneContainer rpc = (RootPaneContainer)window;
        JRootPane rootPane = rpc.getRootPane();
        if(b) {
            rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(desktopKeystroke, "navigateToDesktop");
            rootPane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(desktopKeystroke, "navigateToDesktop");
            rootPane.getActionMap().put("navigateToDesktop", navigateToDesktop);
        } else {
            rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).remove(desktopKeystroke);
            rootPane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).remove(desktopKeystroke);
        }
    }
}
项目:pumpernickel    文件:CustomizedToolbar.java   
/** Are we painting against a dark background?
 * This checks the JVM version, the os, and whether the window's ultimate parent
 * uses Apple's brush-metal-look. 
 */
protected static boolean isDarkBackground(Window w) {
    if(!isMac)
        return false;

    if(JVM.getMajorJavaVersion()<1.5)
        return false;

    while(w!=null) {
        if(w instanceof RootPaneContainer) {
            JRootPane rootPane = ((RootPaneContainer)w).getRootPane();
            Object obj = rootPane.getClientProperty("apple.awt.brushMetalLook");
            if(obj==null) obj = Boolean.FALSE;
            if(obj.toString().equals("true")) {
                return true;
            }
        }
        w = w.getOwner();
    }
    return false;
}
项目:metasfresh    文件:MetasfreshGlassPane.java   
public static final MetasfreshGlassPane getOrNull(final RootPaneContainer rootPaneContainer)
{
    if (rootPaneContainer == null)
    {
        return null;
    }

    final Component glassPaneComp = rootPaneContainer.getGlassPane();
    if (glassPaneComp instanceof MetasfreshGlassPane)
    {
        return (MetasfreshGlassPane)glassPaneComp;
    }
    else
    {
        return null;
    }
}
项目:SpreaD3    文件:DialogFooter.java   
private void setRootPaneContainer(JButton button,RootPaneContainer c) {
    RootPaneContainer lastContainer = (RootPaneContainer)button.getClientProperty("bric.footer.rpc");
    if(lastContainer==c) return;

    if(lastContainer!=null) {
        lastContainer.getRootPane().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).remove(escapeKey);
        lastContainer.getRootPane().getActionMap().remove(escapeKey);

        if(JVM.isMac)
            lastContainer.getRootPane().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).remove(commandPeriodKey);

    }

    if(c!=null) {
        c.getRootPane().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(escapeKey, escapeKey);
        c.getRootPane().getActionMap().put(escapeKey, new ClickAction(button));

        if(JVM.isMac)
            c.getRootPane().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(commandPeriodKey, escapeKey);
    }
    button.putClientProperty("bric.footer.rpc", c);
}
项目:javamelody    文件:MWaitCursor.java   
/**
 * Constructeur : crée le WaitCursor et affiche le sablier.
 * @param comp Component
 */
public MWaitCursor(Component comp) {
    // Curseur de la frame contenant le component
    window = SwingUtilities.windowForComponent(comp);
    windowGlassPaneVisible = window instanceof RootPaneContainer
            && ((RootPaneContainer) window).getGlassPane().isVisible();
    oldWindowCursor = window != null ? window.getCursor() : null;

    // On ne change pas le curseur du component car cela poserait problème en cas d'imbrication
    // pour le remettre à sa valeur initiale (Component.getCursor renvoyant le cursor de son parent si non défini)

    // On active le curseur d'attente
    // (l'utilisation du glassPane rend le curseur visible lors d'un double-clique sur une ligne par ex.
    // et l'utilisation de curseur de la window rend celui-ci visible même si on sort de la fenêtre pour revenir)
    if (window instanceof RootPaneContainer) {
        final Component glassPane = ((RootPaneContainer) window).getGlassPane();
        glassPane.setVisible(true);
        glassPane.setCursor(WAIT_CURSOR);
    }
    if (window != null) {
        window.setCursor(WAIT_CURSOR);
    }
}
项目:seaglass    文件:TitlePaneMaximizeButtonWindowMaximizedState.java   
/**
 * {@inheritDoc}
 */
public boolean isInState(JComponent c) {
    Component parent = c;

    while (parent.getParent() != null) {

        if (parent instanceof RootPaneContainer) {
            break;
        }

        parent = parent.getParent();
    }

    if (parent instanceof JFrame) {
        return (((JFrame) parent).getExtendedState() & Frame.MAXIMIZED_BOTH) != 0;
    } else if (parent instanceof JInternalFrame) {
        return ((JInternalFrame) parent).isMaximum();
    }

    return false;
}
项目:incubator-taverna-workbench    文件:Helper.java   
/**
 * Set up a key-press catcher for the specified component such that when F1
 * is pressed it should help for the component where the cursor is.
 *
 * @param rootpanecontainer
 */
public static void setKeyCatcher(final RootPaneContainer rootpanecontainer) {
    @SuppressWarnings("serial")
    AbstractAction theAction = new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            Component component = (Component) rootpanecontainer;
            Container container = (Container) rootpanecontainer;
            logger.info("frame action F1 pressed with source "
                    + evt.getSource().getClass().getName());
            Point mousePosition = getPointerInfo().getLocation();
            Point framePosition = component.getLocation();
            Point relativePosition = (Point) mousePosition.clone();
            relativePosition.translate(-framePosition.x, -framePosition.y);
            Component c = container.findComponentAt(relativePosition);
            if (c != null)
                logger.info("F1 pressed in a " + c.getClass().getName());
            showHelpWithinContainer(rootpanecontainer, c);
        }
    };

    JRootPane pane = rootpanecontainer.getRootPane();
    setKeyCatcher(pane, theAction);
}
项目:CodenameOne    文件:BlockingAction.java   
public final void actionPerformed(ActionEvent e) {
    RootPaneContainer r = (RootPaneContainer)ResourceEditorApp.getApplication().getMainFrame();
    glassPane = r.getGlassPane();
    final ImageIcon progress = new ImageIcon(getClass().getResource("/progress.gif"));
    final JComponent c = new JLabel(progress);
    c.addMouseListener(new MouseAdapter() {});
    c.addKeyListener(new KeyAdapter() {});
    r.setGlassPane(c);
    c.setVisible(true);
    t = new Timer(100, new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            rotation += 10;
            if(rotation > 359) {
                rotation = 0;
            }
            c.repaint();
        }
    });
    t.setRepeats(true);
    t.start();
    start();
    new Thread(this).start();
}
项目:CodenameOne    文件:BlockingAction.java   
public final void run() {
    try {
        exectute();
        SwingUtilities.invokeAndWait(new Runnable() {
            public void run() {
                afterComplete();
            }
        });
    } catch(Exception err) {
        err.printStackTrace();
    } finally {
        t.stop();
        RootPaneContainer r = (RootPaneContainer)ResourceEditorApp.getApplication().getMainFrame();
        r.setGlassPane(glassPane);
    }
}
项目:CodenameOne    文件:BaseForm.java   
public synchronized void setOverrideMode(boolean overrideMode, java.awt.Component c) {
    RootPaneContainer r = (RootPaneContainer)SwingUtilities.windowForComponent(c);
    if(overrideMode) {
        if(overrideImage == null) {
            overrideImage = new ImageIcon(getClass().getResource("/override_stamp.png"));
        }
        PainterGlasspane pg = new PainterGlasspane();
        MattePainter matte = new MattePainter(new Color(0xcc,0xcc, 0xcc, 120)) {
            protected  void doPaint(java.awt.Graphics2D g, java.lang.Object component, int width, int height) {
                super.doPaint(g, component, width, height);
                overrideImage.paintIcon(BaseForm.this, g, 0, 0);
                //g.drawImage(overrideImage.getImage(), width / 2 - overrideImage.getIconWidth() / 2, 0, BaseForm.this);
            }
        };
        pg.setPainter(matte);
        pg.addTarget(this);
        r.setGlassPane(pg);
        pg.setBounds(0, 0, r.getContentPane().getWidth(), r.getContentPane().getHeight());
        pg.setVisible(true);
    } else {
        r.setGlassPane(new JLabel());
    }
}
项目:cn1    文件:BasicToolBarUI.java   
protected RootPaneContainer createFloatingWindow(final JToolBar toolbar) {
    Window owner = SwingUtilities.getWindowAncestor(toolBar);
    while (owner instanceof FloatingWindow) {
        owner = owner.getOwner();
    }
    JDialog floatingFrame;
    if (owner instanceof Dialog) {
        floatingFrame = new FloatingWindow((Dialog)owner, toolbar.getName());
    } else if (owner instanceof Frame) {
        floatingFrame = new FloatingWindow((Frame)owner, toolbar.getName());
    } else {
        floatingFrame = new FloatingWindow((Frame)null, toolbar.getName());
    }

    floatingFrame.setResizable(false);
    floatingFrame.addWindowListener(createFrameListener());
    return floatingFrame;
}
项目:cn1    文件:BlockingAction.java   
public final void actionPerformed(ActionEvent e) {
    RootPaneContainer r = (RootPaneContainer)ResourceEditorApp.getApplication().getMainFrame();
    glassPane = r.getGlassPane();
    final ImageIcon progress = new ImageIcon(getClass().getResource("/progress.gif"));
    final JComponent c = new JLabel(progress);
    c.addMouseListener(new MouseAdapter() {});
    c.addKeyListener(new KeyAdapter() {});
    r.setGlassPane(c);
    c.setVisible(true);
    t = new Timer(100, new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            rotation += 10;
            if(rotation > 359) {
                rotation = 0;
            }
            c.repaint();
        }
    });
    t.setRepeats(true);
    t.start();
    start();
    new Thread(this).start();
}
项目:cn1    文件:BlockingAction.java   
public final void run() {
    try {
        exectute();
        SwingUtilities.invokeAndWait(new Runnable() {
            public void run() {
                afterComplete();
            }
        });
    } catch(Exception err) {
        err.printStackTrace();
    } finally {
        t.stop();
        RootPaneContainer r = (RootPaneContainer)ResourceEditorApp.getApplication().getMainFrame();
        r.setGlassPane(glassPane);
    }
}
项目:cn1    文件:BaseForm.java   
public synchronized void setOverrideMode(boolean overrideMode, java.awt.Component c) {
    RootPaneContainer r = (RootPaneContainer)SwingUtilities.windowForComponent(c);
    if(overrideMode) {
        if(overrideImage == null) {
            overrideImage = new ImageIcon(getClass().getResource("/override_stamp.png"));
        }
        PainterGlasspane pg = new PainterGlasspane();
        MattePainter matte = new MattePainter(new Color(0xcc,0xcc, 0xcc, 120)) {
            protected  void doPaint(java.awt.Graphics2D g, java.lang.Object component, int width, int height) {
                super.doPaint(g, component, width, height);
                overrideImage.paintIcon(BaseForm.this, g, 0, 0);
                //g.drawImage(overrideImage.getImage(), width / 2 - overrideImage.getIconWidth() / 2, 0, BaseForm.this);
            }
        };
        pg.setPainter(matte);
        pg.addTarget(this);
        r.setGlassPane(pg);
        pg.setBounds(0, 0, r.getContentPane().getWidth(), r.getContentPane().getHeight());
        pg.setVisible(true);
    } else {
        r.setGlassPane(new JLabel());
    }
}
项目:jshred    文件:SwingUtils.java   
/**
 * Sets the cancel button for a {@link RootPaneContainer}. Pressing the escape key
 * will also trigger that {@link JButton}.
 *
 * @param dialog
 *            {@link RootPaneContainer} to set the cancel button for
 * @param cancel
 *            Cancel {@link JButton}.
 * @since R7
 */
public static void setCancelKey(RootPaneContainer dialog, JButton cancel) {
    final JButton fCancel = cancel;
    final String name = "CancelAction";

    JLayeredPane lp = dialog.getLayeredPane();
    lp.getActionMap().put(name, new AbstractAction(name) {
        private static final long serialVersionUID = 3760844579897030200L;

        @Override
        public void actionPerformed(ActionEvent e) {
            fCancel.doClick();
        }
    });

    KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
    lp.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(stroke, name);
}
项目:freeVM    文件:BasicToolBarUI.java   
protected RootPaneContainer createFloatingWindow(final JToolBar toolbar) {
    Window owner = SwingUtilities.getWindowAncestor(toolBar);
    while (owner instanceof FloatingWindow) {
        owner = owner.getOwner();
    }
    JDialog floatingFrame;
    if (owner instanceof Dialog) {
        floatingFrame = new FloatingWindow((Dialog)owner, toolbar.getName());
    } else if (owner instanceof Frame) {
        floatingFrame = new FloatingWindow((Frame)owner, toolbar.getName());
    } else {
        floatingFrame = new FloatingWindow((Frame)null, toolbar.getName());
    }

    floatingFrame.setResizable(false);
    floatingFrame.addWindowListener(createFrameListener());
    return floatingFrame;
}
项目:freeVM    文件:BasicToolBarUI.java   
protected RootPaneContainer createFloatingWindow(final JToolBar toolbar) {
    Window owner = SwingUtilities.getWindowAncestor(toolBar);
    while (owner instanceof FloatingWindow) {
        owner = owner.getOwner();
    }
    JDialog floatingFrame;
    if (owner instanceof Dialog) {
        floatingFrame = new FloatingWindow((Dialog)owner, toolbar.getName());
    } else if (owner instanceof Frame) {
        floatingFrame = new FloatingWindow((Frame)owner, toolbar.getName());
    } else {
        floatingFrame = new FloatingWindow((Frame)null, toolbar.getName());
    }

    floatingFrame.setResizable(false);
    floatingFrame.addWindowListener(createFrameListener());
    return floatingFrame;
}
项目:wichtel    文件:TrayIcon.java   
void showJPopupMenu(final MouseEvent e) {
    if (null != popup) {
        if (null == dialog) {
            dialog = new JDialog((Frame) null);
            dialog.setUndecorated(true);
            dialog.setAlwaysOnTop(true);
            final Dimension size = popup.getPreferredSize();

            final Point centerPoint = GraphicsEnvironment.getLocalGraphicsEnvironment().getCenterPoint();
            if (e.getY() > centerPoint.getY()) {
                dialog.setLocation(Platform.MAC_OSX == PLATFORM ? e.getXOnScreen() : e.getX(), Platform.MAC_OSX == PLATFORM ? MAC_MENUBAR_OFFSET : e
                        .getY()
                        - size.height);
            } else {
                dialog.setLocation(Platform.MAC_OSX == PLATFORM ? e.getXOnScreen() : e.getX(), Platform.MAC_OSX == PLATFORM ? MAC_MENUBAR_OFFSET : e
                        .getY());
            }

            dialog.setVisible(true);

            popup.show(((RootPaneContainer) dialog).getContentPane(), 0, 0);

            dialog.toFront();
        }
    }
}
项目:monsiaj    文件:WindowBuilder.java   
@Override
void buildChildren(Interface xml, Container parent, WidgetInfo info) {
    Window w = (Window) parent;
    Iterator i = info.getChildren().iterator();
    if (parent instanceof RootPaneContainer) {
        RootPaneContainer rootPaneContainer = (RootPaneContainer) parent;
        parent = rootPaneContainer.getContentPane();
    }
    while (i.hasNext()) {
        ChildInfo cInfo = (ChildInfo) i.next();
        WidgetInfo wInfo = cInfo.getWidgetInfo();
        Component child = WidgetBuilder.buildWidget(xml, wInfo, parent);
        if (child instanceof JMenuBar) {
            xml.setMenuBar((JMenuBar) child);
        } else {
            w.setChild(child);
        }
        if (child instanceof Fixed) {
            wInfo.setProperty("width", "1024");
            wInfo.setProperty("height", "768");
        }
    }
}
项目:monsiaj    文件:ContainerBuilder.java   
void buildChildren(Interface xml, Container parent, WidgetInfo info) {
    Iterator i = info.getChildren().iterator();
    if (parent instanceof RootPaneContainer) {
        RootPaneContainer rootPaneContainer = (RootPaneContainer)parent;
        parent = rootPaneContainer.getContentPane();
    }
    while (i.hasNext()) {
        ChildInfo cInfo = (ChildInfo)i.next();
        WidgetInfo wInfo = cInfo.getWidgetInfo();
        Component child = WidgetBuilder.buildWidget(xml, wInfo, parent);
        if (child instanceof JMenuBar) {
            xml.setMenuBar((JMenuBar)child);
        } else {
            parent.add(child);
        }
    }
}
项目:incubator-netbeans    文件:ZOrderManager.java   
/** Adds given window (RootPaneContainer) to the set of windows which are tracked.
 */
public void attachWindow (RootPaneContainer rpc) {
    logger.entering(getClass().getName(), "attachWindow");

    if (!(rpc instanceof Window)) {
        throw new IllegalArgumentException("Argument must be subclas of java.awt.Window: " + rpc);   //NOI18N
    }
    if (getWeak(rpc) != null) {
        throw new IllegalArgumentException("Window already attached: " + rpc);   //NOI18N
    }

    zOrder.add(new WeakReference<RootPaneContainer>(rpc));
    ((Window)rpc).addWindowListener(this);
}
项目:incubator-netbeans    文件:ZOrderManager.java   
/** Excludes/reincludes given RootPaneContainer from z-ordering. Excluded RootPaneContainer
 * never returns true from isOnTop call, even if it is on top of window stack.
 * RootPaneContainer that is second on top is returned in such situation.
 *
 * Used to distinguish RootPaneContainer that is being dragged.
 *
 * @param rpc Pane container to exlude or include back into rthe z-ordering.
 * @param exclude true when exclusion is needed, false when normal default
 * behaviour is desirable.
 */
public void setExcludeFromOrder (RootPaneContainer rpc, boolean exclude) {
    if (exclude) {
        excludeSet.add(new WeakReference<RootPaneContainer>(rpc));
    } else {
        WeakReference<RootPaneContainer> ww = getExcludedWeak(rpc);
        if (ww != null) {
            excludeSet.remove(ww);
        }
    }
}
项目:incubator-netbeans    文件:ZOrderManager.java   
public void clear () {
    RootPaneContainer rpc;
    for (WeakReference<RootPaneContainer> elem : zOrder) {
        rpc = elem.get();
        if (rpc != null) {
            ((Window)rpc).removeWindowListener(this);
        }
    }
    zOrder.clear();
}
项目:incubator-netbeans    文件:ZOrderManager.java   
public void windowActivated(WindowEvent e) {
    logger.entering(getClass().getName(), "windowActivated");

    WeakReference<RootPaneContainer> ww = getWeak((RootPaneContainer)e.getWindow());
    if (ww != null) {
        // place as last item in zOrder list
        zOrder.remove(ww);
        zOrder.add(ww);
    } else {
        throw new IllegalArgumentException("Window not attached: " + e.getWindow()); //NOI18N
    }
}
项目:incubator-netbeans    文件:ZOrderManager.java   
private WeakReference<RootPaneContainer> getWeak (RootPaneContainer rpc) {
    for (WeakReference<RootPaneContainer> elem : zOrder) {
        if (elem.get() == rpc) {
            return elem;
        }
    }
    return null;
}
项目:incubator-netbeans    文件:ZOrderManager.java   
private WeakReference<RootPaneContainer> getExcludedWeak (RootPaneContainer rpc) {
    for (WeakReference<RootPaneContainer> elem : excludeSet) {
        if (elem.get() == rpc) {
            return elem;
        }
    }
    return null;
}
项目:swingspy    文件:SwingSpyGlassPane.java   
public SwingSpyGlassPane(RootPaneContainer rootPaneContainer) {
    super(null);
 setName("SwingSpyGlass");
    this.rootPaneContainer = rootPaneContainer;
    this.fontColor = Color.RED.darker();
    this.highlightColor = new Color(0xFFDDDD);
    this.font = new Font("sansserif", Font.BOLD, 14);
    this.alpha = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.5f);
    setOpaque(false);
}
项目:VASSAL-src    文件:Map.java   
/**
 * When a game is started, create a top-level window, if none exists.
 * When a game is ended, remove all boards from the map.
 *
 * @see GameComponent
 */
public void setup(boolean show) {
  if (show) {
    final GameModule g = GameModule.getGameModule();

    if (shouldDockIntoMainWindow()) {
      mainWindowDock.showComponent();
      final int height = ((Integer)
        Prefs.getGlobalPrefs().getValue(MAIN_WINDOW_HEIGHT)).intValue();
      if (height > 0) {
        final Container top = mainWindowDock.getTopLevelAncestor();
        top.setSize(top.getWidth(), height);
      }
      if (toolBar.getParent() == null) {
        g.getToolBar().addSeparator();
        g.getToolBar().add(toolBar);
      }
      toolBar.setVisible(true);
    }
    else {
      if (SwingUtilities.getWindowAncestor(theMap) == null) {
        final Window topWindow = createParentFrame();
        topWindow.addWindowListener(new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            if (useLaunchButton) {
              topWindow.setVisible(false);
            }
            else {
              g.getGameState().setup(false);
            }
          }
        });
        ((RootPaneContainer) topWindow).getContentPane().add("North", getToolBar()); //$NON-NLS-1$
        ((RootPaneContainer) topWindow).getContentPane().add("Center", layeredPane); //$NON-NLS-1$
        topWindow.setSize(600, 400);
        final PositionOption option =
          new PositionOption(PositionOption.key + getIdentifier(), topWindow);
        g.getPrefs().addOption(option);
      }
      theMap.getTopLevelAncestor().setVisible(!useLaunchButton);
      theMap.revalidate();
    }
  }
  else {
    pieces.clear();
    boards.clear();
    if (mainWindowDock != null) {
      if (mainWindowDock.getHideableComponent().isShowing()) {
        Prefs.getGlobalPrefs().getOption(MAIN_WINDOW_HEIGHT)
             .setValue(mainWindowDock.getTopLevelAncestor().getHeight());
      }
      mainWindowDock.hideComponent();
      toolBar.setVisible(false);
    }
    else if (theMap.getTopLevelAncestor() != null) {
      theMap.getTopLevelAncestor().setVisible(false);
    }
  }
  launchButton.setEnabled(show);
  launchButton.setVisible(useLaunchButton);
}
项目:Equella    文件:GlassPaneUtils.java   
public synchronized static <T extends Component> T mount(Component startComponent, boolean stopClosing,
    boolean alwaysRecreateGlasspane, Class<T> paneClass, GlassPaneCallback<T> callback)
{
    RootPaneContainer rootpane = getRootContainer(startComponent);
    if( rootpane != null )
    {
        Component gp = rootpane.getGlassPane();
        if( !alwaysRecreateGlasspane )
        {
            if( paneClass.isAssignableFrom(gp.getClass()) )
            {
                if( !gp.isVisible() )
                {
                    T ogp = paneClass.cast(gp);
                    callback.processExisting(ogp);
                    return ogp;
                }
                else
                {
                    return null;
                }
            }
        }

        T ngp = callback.construct();
        rootpane.setGlassPane(ngp);
        return ngp;
    }
    return null;
}
项目:OpenJSharp    文件:FullScreenHandler.java   
static void addFullScreenListenerTo(final RootPaneContainer window, final FullScreenListener listener) {
    final Object value = window.getRootPane().getClientProperty(CLIENT_PROPERTY);
    if (value instanceof FullScreenHandler) {
        ((FullScreenHandler)value).addListener(listener);
        return;
    }

    if (value != null) return; // some other garbage is in our client property

    final FullScreenHandler newHandler = new FullScreenHandler();
    newHandler.addListener(listener);
    window.getRootPane().putClientProperty(CLIENT_PROPERTY, newHandler);
}
项目:OpenJSharp    文件:FullScreenHandler.java   
static void handleFullScreenEventFromNative(final Window window, final int type) {
    if (!(window instanceof RootPaneContainer)) return; // handles null

    SunToolkit.executeOnEventHandlerThread(window, new Runnable() {
        public void run() {
            final FullScreenHandler handler = getHandlerFor((RootPaneContainer)window);
            if (handler != null) handler.notifyListener(new FullScreenEvent(window), type);
        }
    });
}
项目:jdk8u-jdk    文件:FullScreenHandler.java   
static void addFullScreenListenerTo(final RootPaneContainer window, final FullScreenListener listener) {
    final Object value = window.getRootPane().getClientProperty(CLIENT_PROPERTY);
    if (value instanceof FullScreenHandler) {
        ((FullScreenHandler)value).addListener(listener);
        return;
    }

    if (value != null) return; // some other garbage is in our client property

    final FullScreenHandler newHandler = new FullScreenHandler();
    newHandler.addListener(listener);
    window.getRootPane().putClientProperty(CLIENT_PROPERTY, newHandler);
}