Example usage for java.awt Window remove

List of usage examples for java.awt Window remove

Introduction

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

Prototype

public void remove(int index) 

Source Link

Document

Removes the component, specified by index , from this container.

Usage

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 ww w .j  a va 2s.co 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();
    }
}