Example usage for java.awt Window getInsets

List of usage examples for java.awt Window getInsets

Introduction

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

Prototype

public Insets getInsets() 

Source Link

Document

Determines the insets of this container, which indicate the size of the container's border.

Usage

From source file:Utils.java

/**
 * <p/>/*from w w  w  .j  av  a  2  s  .  c  o  m*/
 * Returns the <code>Point</code> at which a window should be placed in
 * order to be staggered slightly from another &quot;origin&quot; window to
 * ensure that the title areas of both windows remain visible to the user.
 * </p>
 *
 * @param originWindow Window from which the staggered location will be calculated
 *
 * @return location staggered from the upper left location of the origin
 *         window
 */
public static Point getPointForStaggering(Window originWindow) {
    Point origin = originWindow.getLocation();
    Insets insets = originWindow.getInsets();
    origin.x += insets.top;
    origin.y += insets.top;
    return origin;
}

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

public void setSize(int w, int h) {
    boolean resized = false;
    if (w != this.width || h != this.height)
        resized = true;/*  ww w.  j a va  2  s .  c  om*/

    if (!resized && !bwc) {
        return;
    }

    int offx = 0, offy = 0;

    int bitgrabity = window.attr & (15 << 8);
    if (bitgrabity != 0) {
        if (bitgrabity == (7 << 8) || // SouthWest
                bitgrabity == (8 << 8) || // South
                bitgrabity == (9 << 8)) { // SouthEast
            offy = this.height - h;
        }
        if (bitgrabity == (3 << 8) || // NorthEast
                bitgrabity == (6 << 8) || // East
                bitgrabity == (9 << 8)) { // SouthEast
            offx = this.width - w;
        }
    }

    //int originalWidth = this.width, originalHeight = this.height;
    this.width = w;
    this.height = h;
    super.setSize(w + 2 * bw, h + 2 * bw);

    bwc = false;

    if (window.screen.windowmode != WeirdX.InBrowser && window.hasFrame()) {
        java.awt.Window frame = window.getFrame();
        frame.validate();
        Insets insets = frame.getInsets();
        frame.setSize(w + 2 * bw + insets.left + insets.right, h + 2 * bw + insets.top + insets.bottom);
        frame.validate();
    }

    if (window.clss == InputOnly) {
        return;
    }

    if (offi != null && resized) {
        if (w < exposed.x || h < exposed.y) {
            exposed.setBounds(0, 0, 0, 0);
        } else if (w < (exposed.x + exposed.width) || h < (exposed.y + exposed.height)) {
            exposed.setBounds(exposed.x, exposed.y,
                    (exposed.width < (w - exposed.x) ? exposed.width : (w - exposed.x)),
                    (exposed.height < (h - exposed.y) ? exposed.height : (h - exposed.y)));
        }

        try {
            Image tmp = offi;
            Graphics tmpg = offg;

            offi = createImage(w, h);
            offg = offi.getGraphics();
            window.makeBackgroundTile(0, 0, w, h);
            if (bitgrabity != 0) {
                offg.drawImage(tmp, 0, 0, this);
            }

            if (offx != 0 || offy != 0) {
                int copyx = 0, copyy = 0, copyw = w, copyh = h, dx = 0, dy = 0;
                if (offy > 0) {
                    copyy = offy;
                    copyh = h - offy;
                    dy = offy * -1;
                } else if (offy < 0) {
                    dy = offy * -1;
                }
                if (offx > 0) {
                    copyx = offx;
                    copyw = w - offx;
                    dx = offx * -1;
                } else if (offx < 0) {
                    dx = offx * -1;
                }
                offg.copyArea(copyx, copyy, copyw, copyh, dx, dy);
            }

            if (tmp != offi) {
                tmp.flush();
                tmpg.dispose();
            }

            if (bitgrabity == 0) {
                exposed.setBounds(0, 0, 0, 0);
                window.makeBackgroundTile(0, 0, width, height);
            }
            window.currentGC = null;
        } catch (Exception e) {
            LOG.error(e);
            offi = null;
            offg = null;
        } catch (java.lang.OutOfMemoryError e) {
            LOG.error(e);
            offi = null;
            offg = null;
        }
        //System.out.println("DDXW: "+getBackground());
    }
}

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

public void setSize(int w, int h) {
    boolean resized = false;
    if (w != this.width || h != this.height)
        resized = true;/* w  w  w  . ja v a 2s .  co m*/

    if (!resized && !bwc) {
        return;
    }

    int offx = 0, offy = 0;

    int bitgrabity = window.attr & (15 << 8);
    if (bitgrabity != 0) {
        if (bitgrabity == (7 << 8) || // SouthWest
                bitgrabity == (8 << 8) || // South
                bitgrabity == (9 << 8)) { // SouthEast
            offy = this.height - h;
        }
        if (bitgrabity == (3 << 8) || // NorthEast
                bitgrabity == (6 << 8) || // East
                bitgrabity == (9 << 8)) { // SouthEast
            offx = this.width - w;
        }
    }

    //int originalWidth=this.width, originalHeight = this.height;
    this.width = w;
    this.height = h;
    super.setSize(w + 2 * bw, h + 2 * bw);

    bwc = false;

    if (window.screen.windowmode != WeirdX.InBrowser && window.hasFrame()) {
        java.awt.Window frame = window.getFrame();
        frame.validate();
        Insets insets = frame.getInsets();
        frame.setSize(w + 2 * bw + insets.left + insets.right, h + 2 * bw + insets.top + insets.bottom);
        frame.validate();
    }

    if (window.clss == InputOnly) {
        return;
    }

    if (offi != null && resized) {
        if (w < exposed.x || h < exposed.y) {
            exposed.setBounds(0, 0, 0, 0);
        } else if (w < (exposed.x + exposed.width) || h < (exposed.y + exposed.height)) {
            exposed.setBounds(exposed.x, exposed.y,
                    (exposed.width < (w - exposed.x) ? exposed.width : (w - exposed.x)),
                    (exposed.height < (h - exposed.y) ? exposed.height : (h - exposed.y)));
        }

        try {
            Image tmp = offi;
            Graphics tmpg = offg;

            offi = createImage(w, h);
            offg = offi.getGraphics();
            window.makeBackgroundTile(0, 0, w, h);
            if (bitgrabity != 0) {
                offg.drawImage(tmp, 0, 0, this);
            }

            if (offx != 0 || offy != 0) {
                int copyx = 0, copyy = 0, copyw = w, copyh = h, dx = 0, dy = 0;
                if (offy > 0) {
                    copyy = offy;
                    copyh = h - offy;
                    dy = offy * -1;
                } else if (offy < 0) {
                    dy = offy * -1;
                }
                if (offx > 0) {
                    copyx = offx;
                    copyw = w - offx;
                    dx = offx * -1;
                } else if (offx < 0) {
                    dx = offx * -1;
                }
                offg.copyArea(copyx, copyy, copyw, copyh, dx, dy);
            }

            if (tmp != offi) {
                tmp.flush();
                tmpg.dispose();
            }

            if (bitgrabity == 0) {
                exposed.setBounds(0, 0, 0, 0);
                window.makeBackgroundTile(0, 0, width, height);
            }
            window.currentGC = null;
        } catch (Exception e) {
            LOG.equals(e);
            offi = null;
            offg = null;
        } catch (java.lang.OutOfMemoryError e) {
            LOG.error(e);
            offi = null;
            offg = null;
        }
        //System.out.println("DDXW: "+getBackground());
    }
}

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

public void setVisible(boolean b) {
    if (b) {//from w  w  w  . java  2 s.c  o  m
        if (offi == null && window.clss != InputOnly) {
            allocImage();
        }
        if (window != window.screen.root && !isVisible()) {
            exposed.setBounds(0, 0, 0, 0);
        }
        super.setVisible(true);
        if (window.screen.windowmode != WeirdX.InBrowser && window.hasFrame()) {
            java.awt.Window frame = window.getFrame();

            if (frame instanceof java.awt.Frame) {
                frame.add("Center", this);
                frame.pack();
                synchronized (XWindow.LOCK) {
                    Property p = window.getProperty();
                    while (p != null) {
                        if (p.propertyName == 39)
                            break;
                        p = p.next;
                    }
                    if (p != null && p.type == 31) {
                        String title = "";
                        if (p.size > 0) {
                            title = new String(p.data);
                        }
                        ((java.awt.Frame) (frame)).setTitle(title);
                    }
                }
            } else {
                frame.add(this);
            }

            frame.validate();
            Insets insets = frame.getInsets();
            frame.setSize(window.width + window.borderWidth * 2 + insets.left + insets.right,
                    window.height + window.borderWidth * 2 + insets.top + insets.bottom);
            super.setLocation(insets.left, insets.top);
            frame.validate();
        }
    } else {
        if (isVisible()) {
            super.setVisible(false);
            if (window != window.screen.root && window.screen.root.width * window.screen.root.height
                    / 4 <= window.width * window.height) {
                freeImage();
                exposed.setBounds(0, 0, 0, 0);
            }
        }
    }
}

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

static final void reqConfigureWindow(Client c) throws IOException {
    int foo;//from   w w  w  .  ja va 2  s  .  c o m
    int n;
    InputOutput io = c.client;
    foo = io.readInt();
    XWindow win = c.lookupWindow(foo);
    if (win == null) {
        c.errorValue = foo;
        c.errorReason = 3; // BadWindow
    }

    int mask = io.readShort();
    io.readPad(2);
    c.length -= 3;
    if (c.errorReason != 0) {
        return;
    }
    if (((win.clss == InputOnly) && (mask & IllegalInputOnlyConfigureMask) != 0)
            || ((mask & CWSibling) != 0 && (mask & CWStackMode) == 0)) {
        c.errorReason = 8; // BadMatch
        return;
    }

    int index;
    int x, y;
    int w = win.width;
    int h = win.height;
    int bw = win.borderWidth;
    XWindow sib = null;

    synchronized (LOCK) {
        win = c.lookupWindow(win.id);
        if (win == null) {
            c.errorValue = win.id;
            c.errorReason = 3; // BadWindow
            return;
        }
        if (win.screen.root != win && win.parent == null)
            return;
        if (win.parent != null) {
            x = win.x - win.parent.x - bw;
            y = win.y - win.parent.y - bw;
        } else {
            x = win.x;
            y = win.y;
        }

        mask &= 0x7f;

        int beforex = x, beforey = y;

        int smode = 0;
        int tmp = mask;
        while (tmp != 0 && c.length != 0) {
            index = lowbit(tmp);
            tmp &= ~index;
            switch (index) {
            case CWX:
                foo = io.readInt();
                foo = (short) (foo & 0xffff);
                if (foo == x) {
                    mask -= CWX;
                } else {
                    x = (short) (foo);
                }
                break;
            case CWY:
                foo = io.readInt();
                foo = (short) (foo & 0xffff);
                if (foo == y) {
                    mask -= CWY;
                } else {
                    y = (short) (foo);
                }
                break;
            case CWWidth:
                foo = io.readInt();
                foo = (foo & 0xffff);
                if (w == foo) {
                    mask -= CWWidth;
                } else {
                    w = foo;
                }
                break;
            case CWHeight:
                foo = io.readInt();
                foo = (foo & 0xffff);
                if (h == foo) {
                    mask -= CWHeight;
                } else {
                    h = foo;
                }
                break;
            case CWBorderWidth:
                foo = io.readInt();
                foo = (foo & 0xffff);
                bw = foo;
                break;
            case CWSibling:
                foo = io.readInt();
                sib = c.lookupWindow(foo);
                if (sib == null) {
                    c.errorValue = foo;
                    c.errorReason = 3; // BadWindow
                } else if ((sib.parent != win.parent) || (sib == win)) {
                    c.errorReason = 8; // BadMatch
                }
                break;
            case CWStackMode:
                foo = io.readInt();
                foo &= 0xff;
                smode = foo;
                if ((smode != TopIf) && (smode != BottomIf) && (smode != Opposite) && (smode != Above)
                        && (smode != Below)) {
                    c.errorValue = foo;
                    c.errorReason = 2; // BadValue
                }
                break;
            default:
                c.errorValue = mask;
                c.errorReason = 2; // BadValue
                return;
            }
            c.length--;
            if (c.errorReason != 0) {
                return;
            }
        }
        if (c.length != 0) {
            c.errorValue = mask;
            c.errorReason = 2; // BadValue
            return;
        }

        if (mask == 0) {
            return;
        }

        if (win.parent == null)
            return;

        if ((mask & CWStackMode) != 0) {
            sib = win.getPlaceInTheStack(sib, win.parent.x + x, win.parent.y + y, w + bw * 2, h + bw * 2,
                    smode);
        } else {
            sib = win.nextSib;
        }

        if (((win.attr & overrideRedirect) == 0) && (win.parent.redirectSend())) {
            c.cevent.mkConfigureRequest(((mask & CWStackMode) != 0) ? smode : Above, win.parent.id, win.id,
                    ((mask & CWSibling) != 0) ? sib.id : 0, x, y, w, h, bw, mask);
            if (win.parent.sendEvent(c.cevent, 1, Event.SubstructureRedirectMask, c) == 1) {
                return;
            }

        }

        int action = Restack;
        if ((mask & (CWX | CWY)) != 0 && (mask & (CWHeight | CWWidth)) == 0) {
            action = Move;
        } else if ((mask & ChangeMask) != 0) {
            if (w == 0 || h == 0) {
                c.errorValue = 0;
                c.errorReason = 2; // BadBalue;
                return;
            }
            action = Resize;
        }

        if (action == Resize) {
            boolean sizec = ((w != win.width) || (h != win.height));
            if (sizec && (((win.eventMask | win.getOtherEventMask()) & Event.ResizeRedirectMask) != 0)) {
                c.cevent.mkResizeRequest(win.id, w, h);
                if (win.sendEvent(c.cevent, 1, Event.ResizeRedirectMask, c) == 1) {
                    w = win.width;
                    h = win.height;
                    sizec = false;
                }
            }
            if (!sizec) {
                if ((mask & (CWX | CWY)) != 0)
                    action = Move;
                else if ((mask & (CWStackMode | CWBorderWidth)) != 0) {
                    action = Restack;
                } else {
                    return;
                }
            }
        }

        if ((action == Resize) || (((mask & CWX) != 0) && x != beforex) || (((mask & CWY) != 0) && y != beforey)
                || (((mask & CWBorderWidth) != 0) && bw != win.borderWidth)
                || (((mask & CWStackMode) != 0) && win.nextSib != sib)) {
            if (win.substrSend()) {
                c.cevent.mkConfigureNotify(win.id, (sib != null ? sib.id : 0), x, y, w, h, bw,
                        (win.attr & overrideRedirect) != 0 ? 0 : 1);
                win.sendEvent(c.cevent, 1, null);
            }

            if ((mask & CWBorderWidth) != 0) {
                if (action == Restack) {
                    action = Move;
                    win.borderWidth = bw;
                    win.ddxwindow.setBorder(bw);
                } else if ((action == Move) && ((beforex + win.borderWidth) == x + bw)
                        && ((beforey + win.borderWidth) == y + bw)) {
                    action = Reborder;
                } else {
                    win.borderWidth = bw;
                    win.ddxwindow.setBorder(bw);
                }
            }

            if ((mask & CWStackMode) != 0) {
                win.reflectStackChange(sib);
            }

            if (((mask & CWX) != 0) || ((mask & CWY) != 0) || ((mask & CWWidth) != 0)
                    || ((mask & CWHeight) != 0) || ((mask & CWBorderWidth) != 0)) {
                win.origin.x = x + bw;
                win.origin.y = y + bw;

                int dx, dy, dw, dh;
                dx = dy = dw = dh = 0;
                dw = w - win.width;
                dh = h - win.height;
                win.height = h;
                win.width = w;

                int newx = win.parent.x + x + bw;
                int newy = win.parent.y + y + bw;

                int oldx, oldy;
                oldx = win.x;
                oldy = win.y;

                x = win.x = newx;
                y = win.y = newy;

                XWindow wToValidate = win.moveInStack(sib);
                if (((mask & CWWidth) != 0) || ((mask & CWHeight) != 0) || ((mask & CWBorderWidth) != 0)) {
                    if (win.screen.windowmode != WeirdX.InBrowser && win.hasFrame()) {
                        java.awt.Window frame = win.getFrame();
                        frame.validate();
                        Insets insets = frame.getInsets();
                        frame.setSize(win.width + win.borderWidth * 2 + insets.left + insets.right,
                                win.height + win.borderWidth * 2 + insets.bottom + insets.top);
                        frame.validate();
                    }

                    win.ddxwindow.setSize(win.width, win.height);
                }

                win.resizeChildrenWinSize(x - oldx, y - oldy, dw, dh);
                win.ddxwindow.setLocation(win.origin.x - win.borderWidth + win.parent.borderWidth,
                        win.origin.y - win.borderWidth + win.parent.borderWidth);

            }
            return;
        } else {
            return;
        }
    }
}

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

void reparent(XWindow newparent, int xx, int yy, Client c) throws IOException {
    boolean wasMapped;

    synchronized (LOCK) {
        if (parent == null)
            return;

        int bw = borderWidth;
        wasMapped = ((attr & mapped) != 0);
        XWindow prev;/*from  w w  w  .j  a  v  a2 s  .  c o  m*/

        makeOptional();

        if (wasMapped) {
            unmapWindow(false);
        }

        c.cevent.mkReparentNotify(id, id, newparent.id, xx, yy, ((attr & overrideRedirect) != 0 ? 1 : 0));

        sendEvent(c.cevent, 1, newparent);

        prev = parent;
        if (prev.firstChild == this)
            prev.firstChild = nextSib;
        if (prev.lastChild == this)
            prev.lastChild = prevSib;

        if (nextSib != null)
            nextSib.prevSib = prevSib;
        if (prevSib != null)
            prevSib.nextSib = nextSib;

        parent = newparent;

        nextSib = newparent.firstChild;
        prevSib = null;
        if (newparent.firstChild != null)
            newparent.firstChild.prevSib = this;
        else
            newparent.lastChild = this;
        newparent.firstChild = this;

        origin.x = (short) (xx);
        origin.y = (short) (yy);
        x = (short) (xx + newparent.x);
        y = (short) (yy + newparent.y);

        if (screen.windowmode != WeirdX.InBrowser && hasFrame()) {
            java.awt.Window frame = getFrame();
            frame.remove((java.awt.Component) ddxwindow);
            //   frame.dispose();                                        
            delFrame();
        }
        if (screen.windowmode != WeirdX.InBrowser && newparent == screen.root) {
            java.awt.Window frame = getFrame();
            /*if(frame instanceof JFrame){                               
              ((JFrame)frame).setJMenuBar(null);                       
              ((JFrame)frame).getContentPane().setLayout(null);        
                ((JFrame)frame).setResizable(false);                                 
            }                                                          
            else*/ if (frame instanceof Frame) {
                ((Frame) frame).setMenuBar(null);
                ((Frame) frame).setResizable(true);
            }

            ddxwindow.setLocation(0, 0);

            frame.add((java.awt.Component) ddxwindow);

            frame.validate();
            Insets insets = frame.getInsets();
            frame.setSize(this.width + this.borderWidth * 2 + insets.left + insets.right,
                    this.height + this.borderWidth * 2 + insets.bottom + insets.top);
            frame.validate();

            if (frame instanceof Frame) {
                addWindowListener((java.awt.Frame) frame);
                addComponentListener((java.awt.Frame) frame);
            }
        } else {
            newparent.ddxwindow.add((java.awt.Component) ddxwindow, 0); // ???
            ddxwindow.setLocation(origin.x - borderWidth + parent.borderWidth,
                    origin.y - borderWidth + parent.borderWidth);
        }

        resizeChildrenWinSize(0, 0, 0, 0);

        if (wasMapped) {
            mapWindow(c);
        }

        recalculateDeliverableEvents();
    }
}

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

XWindow(int wid, XWindow prnt, int x, int y, int width, int height, int bwidth, int clss, byte depth,
        Client client, int visual, int msk) throws IOException {
    this(wid);/*from w  ww  .  j  a  v  a  2s. co m*/
    WindowOpt opt;
    this.client = client;
    this.parent = prnt;
    screen = prnt.screen;

    if (clss == CopyFromParent)
        clss = prnt.clss;
    this.clss = clss;

    if ((clss != InputOutput) && (clss != InputOnly)) {
        client.errorValue = clss;
        client.errorReason = 2; // BadValue;
        return;
    }

    if ((clss != InputOnly) && (prnt.clss == InputOnly)) {
        client.errorValue = clss;
        client.errorReason = 8; // BadMatch;
        return;
    }
    if ((clss == InputOnly) && ((bwidth != 0) || (depth != 0))) {
        client.errorValue = 0;
        client.errorReason = 8; // BadMatch;
        return;
    }

    if ((clss == InputOutput) && (depth == 0)) {
        depth = prnt.depth;
    }

    opt = prnt.optional;
    if (opt == null) {
        opt = prnt.findOptional().optional;
    }
    if (visual == CopyFromParent) {
        visual = opt.visual;
    }
    if ((visual != opt.visual) || (depth != prnt.depth)) {
        boolean foo = false;
        Depth pdepth;
        for (int i = 0; i < screen.depth.length; i++) {
            pdepth = screen.depth[i];
            if (depth == pdepth.depth || depth == 0) {
                if (pdepth.visual != null) {
                    for (int j = 0; j < pdepth.visual.length; j++) {
                        if (visual == pdepth.visual[j].id) {
                            foo = true;
                            break;
                        }
                    }
                }
            }
        }
        if (!foo) {
            client.errorValue = 0;
            client.errorReason = 8; // BadMatch;
            return;
        }
    }
    if (((msk & (CWBorderPixmap | CWBorderPixel)) == 0) && (clss != InputOnly) && (depth != prnt.depth)) {
        client.errorValue = 0;
        client.errorReason = 8; // BadMatch;
        return;
    }

    this.depth = depth;
    if (depth == prnt.depth) {
        this.bitsPerPixel = prnt.bitsPerPixel;
    } else {
        int ii = 0;
        while (ii < Format.format.length) {
            if (Format.format[ii].depth == screen.rootDepth)
                break;
            ii++;
        }
        if (ii == Format.format.length) {
            // ???
            ii = 0;
        }
        this.bitsPerPixel = Format.format[ii].bpp;
    }

    this.type = prnt.type;
    if (clss == InputOnly)
        this.type = UNDRAWABLE_WINDOW;

    setDefault();

    if (visual != opt.visual) {
        makeOptional();
        this.optional.visual = visual;
        this.optional.colormap = screen.defaultColormap;
    }
    this.borderWidth = bwidth;
    attr &= ~backgroundState;
    attr &= ~borderIsPixel;
    attr |= (prnt.attr & borderIsPixel);

    this.border = prnt.border.dup();

    if ((attr & borderIsPixel) == 0) {
        this.border.pixmap.ref();
    }
    this.origin.x = (short) (x + bwidth);
    this.origin.y = (short) (y + bwidth);
    this.width = width;
    this.height = height;
    this.x = (short) (prnt.x + x + bwidth);
    this.y = (short) (prnt.y + y + bwidth);

    synchronized (LOCK) {
        this.nextSib = prnt.firstChild;
        if (prnt.firstChild != null)
            prnt.firstChild.prevSib = this;
        else
            prnt.lastChild = this;
        prnt.firstChild = this;
    }

    if ((msk & CWEventMask) == 0) {
        recalculateDeliverableEvents();
    }

    msk &= 0x7fff;
    if (msk != 0) {
        changeAttr(client, msk);
    }

    if (client.errorReason != 0) {
        this.delete();
        return;
    }

    if ((msk & CWBackingStore) != 0 && (defaultBackingStore != 0)) {
        attr &= ~backingStore;
        attr |= (defaultBackingStore << backingStoreOffset);
        attr |= forcedBS;
    }

    //  ddxwindow=new DDXWindow();
    try {
        ddxwindow = (DDXWindow) dDXWindow.newInstance();
    } catch (Exception e) {
        LOG.error(e);
        /*ddxwindow=new DDXWindow();*/ }
    ddxwindow.init(this);

    try {
        if (screen.windowmode != WeirdX.InBrowser && prnt == screen.root) {
            final java.awt.Window frame = getFrame();
            /*
            if(frame instanceof JFrame){                               
              ((JFrame)frame).setJMenuBar(null);                       
              ((JFrame)frame).getContentPane().setLayout(null);        
                ((JFrame)frame).setResizable(false);                                 
            }                                                          
            else*/ if (frame instanceof Frame) {
                ((Frame) frame).setMenuBar(null);
                ((Frame) frame).setResizable(true);
            }

            ddxwindow.setLocation(0, 0);

            //   if(frame instanceof JFrame){                               
            //     ((JFrame)frame).getContentPane().add((java.awt.Component)ddxwindow);
            //   }                                                          
            //   else{                                                      
            frame.add((java.awt.Component) ddxwindow);
            //   }                                                          

            frame.pack();
            Insets insets = frame.getInsets();
            /*
            frame.setSize(this.width+this.borderWidth*2+             
                     insets.left+insets.right,                  
                     this.height+this.borderWidth*2+            
                     insets.bottom+insets.top);                 
            */
            frame.setLocation(this.origin.x - this.borderWidth + parent.borderWidth,
                    this.origin.y - this.borderWidth + parent.borderWidth);

            if (frame instanceof Frame) {
                addWindowListener((java.awt.Frame) frame);
                addComponentListener((java.awt.Frame) frame);
            }
        } else {
            ddxwindow.setLocation(origin.x - borderWidth + parent.borderWidth,
                    origin.y - borderWidth + parent.borderWidth);
            prnt.ddxwindow.add((java.awt.Component) ddxwindow, 0);
        }
        if ((attr & cursorIsNone) == 0) {
            XCursor cur = getCursor();
            if (cur != null) {
                ddxwindow.setCursor(cur.cursor);
            }
        }
        if (bwidth > 0) {
            ddxwindow.setBorderPixmap(border.pixmap);
        }
    } catch (Exception ee) {
        //System.out.println("error: Window?? "+ee);
    }

    if (prnt.subSend()) {
        client.cevent.mkCreateNotify(prnt.id, id, x, y, width, height, borderWidth,
                (attr & overrideRedirect) != 0 ? 0 : 1);
        prnt.sendEvent(client.cevent, 1, null);
    }
}

From source file:org.eclipse.wb.internal.swing.utils.SwingImageUtils.java

private static Insets getWindowInsets(final Window window) throws Exception {
    return SwingUtils.runObjectLaterAndWait(new RunnableObjectEx<Insets>() {
        public Insets runObject() throws Exception {
            return window.getInsets();
        }/*from   w  w  w .  j av a  2  s  .com*/
    });
}