Example usage for java.awt Frame addComponentListener

List of usage examples for java.awt Frame addComponentListener

Introduction

In this page you can find the example usage for java.awt Frame addComponentListener.

Prototype

public synchronized void addComponentListener(ComponentListener l) 

Source Link

Document

Adds the specified component listener to receive component events from this component.

Usage

From source file:com.jcraft.weirdx.XWindow.java

private void addComponentListener(java.awt.Frame foo) {
    final java.awt.Frame frame = foo;
    frame.addComponentListener(new java.awt.event.ComponentAdapter() {
        public void componentResized(java.awt.event.ComponentEvent e) {
            if (parent == null)
                return;
            Rectangle rectangle = frame.getBounds();
            if (rectangle.width == 0 || rectangle.height == 0)
                return;
            if (frame_width != rectangle.width || frame_height != rectangle.height) {
                Insets insets = frame.getInsets();
                synchronized (XWindow.LOCK) {
                    try {
                        Point point = frame.getLocation();
                        int ww = rectangle.width - insets.left - insets.right - borderWidth * 2;
                        int hh = rectangle.height - insets.top - insets.bottom - borderWidth * 2;
                        if (ww > 0 && hh > 0) {
                            ddxwindow.setSize(ww, hh);
                            frame.pack();
                            Event event = new Event();
                            event.mkConfigureNotify(id, id, (rectangle.x + insets.left),
                                    (rectangle.y + insets.top), ww, hh, borderWidth,
                                    (attr & (1 << 16)) != 0 ? 1 : 0);
                            sendEvent(event, 1, null);
                            frame_x = rectangle.x;
                            frame_y = rectangle.y;
                            frame_width = rectangle.width;
                            frame_height = rectangle.height;
                        }/*from ww w  .ja v a2s .  co m*/
                    } catch (Exception ee) {
                        LOG.error(ee);
                    }
                }
            }
        }
    });
}