Example usage for java.awt Window getComponentListeners

List of usage examples for java.awt Window getComponentListeners

Introduction

In this page you can find the example usage for java.awt Window getComponentListeners.

Prototype

public synchronized ComponentListener[] getComponentListeners() 

Source Link

Document

Returns an array of all the component listeners registered on this component.

Usage

From source file:Utils.java

/**
 * Installs/resets a ComponentListener to resize the
 * given window to minWidth/Height if needed.
 *
 * @param window//ww w  .  j a va  2s  .  c  om
 * @param minWidth
 * @param minHeight
 */
public static void setMinimumSizeManager(Window window, int minWidth, int minHeight) {
    ComponentListener[] listeners = window.getComponentListeners();
    ComponentListener listener = null;
    for (ComponentListener l : listeners) {
        if (l instanceof MinSizeComponentListener) {
            listener = l;
            break;
        }
    }
    if (listener == null) {
        window.addComponentListener(new MinSizeComponentListener(window, minWidth, minHeight));
    } else {
        ((MinSizeComponentListener) listener).resetSizes(minWidth, minHeight);
    }
}