Java Window removeWindow(Window w)

Here you can find the source of removeWindow(Window w)

Description

Removes a window from the set (i.e.

License

Open Source License

Parameter

Parameter Description
w the window to remove

Declaration

public static void removeWindow(Window w) 

Method Source Code

//package com.java2s;
/**/*from  w w w .  j a v a  2s.co m*/
 * Tentackle - a framework for java desktop applications
 * Copyright (C) 2001-2008 Harald Krake, harald@krake.de, +49 7722 9508-0
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

import java.awt.Dialog;

import java.awt.Event;

import java.awt.Window;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import java.util.List;
import java.util.Set;

import javax.swing.event.EventListenerList;

public class Main {
    private static Set<Window> windows;
    private static EventListenerList windowListeners;
    private static List<Dialog> modalDialogs;

    /**
     * Removes a window from the set (i.e. window is hidden or closed now)
     * @param w the window to remove
     */
    public static void removeWindow(Window w) {
        synchronized (windows) {
            if (windows.remove(w)) {
                if (w instanceof Dialog && ((Dialog) w).isModal()) {
                    modalDialogs.remove(w);
                }
                fireWindowActionPerformed(new ActionEvent(w, Event.ACTION_EVENT, "remove")); // NOI18N
            }
        }
    }

    /**
     * notified all window-listeners
     */
    private static void fireWindowActionPerformed(ActionEvent e) {
        Object[] lList = windowListeners.getListenerList();
        for (int i = lList.length - 2; i >= 0; i -= 2) {
            if (lList[i] == ActionListener.class) {
                ((ActionListener) lList[i + 1]).actionPerformed(e);
            }
        }
    }
}

Related

  1. installPrefsHandler(final Preferences prefs, final String name, Window window)
  2. isResizable(Window window)
  3. modifyDimensions(Window window)
  4. openWindow(final JPanel panel)
  5. putWindowNormalBounds(Window window, Rectangle bounds)
  6. repaintMnemonicsInWindow(Window w)
  7. setWindowAlpha(Window w, int value)
  8. setWindowOpacity(Window window, float opacity)
  9. show(final Container container, final boolean visible, Window appearOnLeftSide)