Example usage for java.awt Container removeAll

List of usage examples for java.awt Container removeAll

Introduction

In this page you can find the example usage for java.awt Container removeAll.

Prototype

public void removeAll() 

Source Link

Document

Removes all the components from this container.

Usage

From source file:Main.java

/**
 * Destroys container by destroying its childs structure and removing all
 * listeners./*from   w  w  w.  j a  v a2 s .c  o  m*/
 *
 * @param container
 *            container to destroy
 */
public static void destroyContainer(final Container container) {
    for (final Container toDestroy : collectAllContainers(container)) {
        toDestroy.removeAll();
        toDestroy.setLayout(null);

        for (final MouseListener listener : toDestroy.getMouseListeners()) {
            toDestroy.removeMouseListener(listener);
        }
        for (final MouseMotionListener listener : toDestroy.getMouseMotionListeners()) {
            toDestroy.removeMouseMotionListener(listener);
        }
        for (final MouseWheelListener listener : toDestroy.getMouseWheelListeners()) {
            toDestroy.removeMouseWheelListener(listener);
        }
        for (final KeyListener listener : toDestroy.getKeyListeners()) {
            toDestroy.removeKeyListener(listener);
        }
        for (final ComponentListener listener : toDestroy.getComponentListeners()) {
            toDestroy.removeComponentListener(listener);
        }
        for (final ContainerListener listener : toDestroy.getContainerListeners()) {
            toDestroy.removeContainerListener(listener);
        }
        if (toDestroy instanceof JComponent) {
            final JComponent jComponent = (JComponent) toDestroy;
            for (final AncestorListener listener : jComponent.getAncestorListeners()) {
                jComponent.removeAncestorListener(listener);
            }
        }
    }
}

From source file:Main.java

private static void disassemble(Component component) {
    if (component instanceof Container) {
        Container container = (Container) component;
        int nSubcomponents = container.getComponentCount();
        for (int i = 0; i < nSubcomponents; ++i) {
            disassemble(container.getComponent(i));
        }//from   w  w w . j a  v a  2 s.c  o  m
        container.removeAll();
    }
}

From source file:Main.java

private static void disposeContainer(Container container) {
    if (container == null) {
        return;/*from w w  w .ja  v  a 2 s  .  co m*/
    }

    if (container instanceof JComponent) {
        disposeComponent((JComponent) container);
    }
    container.removeAll();
}

From source file:com.diversityarrays.wizard.WizardRunner.java

protected void handleWizardEnded(WizardEndedReason reason) {

    if (handler != null) {
        handler.execute(reason);//w  w  w  .j  a  v a  2s  .com

    }

    status.setText(reason.toString());
    WizardRunner.this.setEnabled(false);

    RootPaneContainer rpc = ((RootPaneContainer) window);

    rpc.getContentPane().remove(this);

    Container cp = rpc.getContentPane();
    cp.removeAll();

    JLabel label = new JLabel(reason.toString());

    Box n = Box.createHorizontalBox();
    n.add(Box.createHorizontalGlue());
    n.add(label);
    n.add(Box.createHorizontalGlue());
    cp.add(n, BorderLayout.CENTER);

    Box box = Box.createHorizontalBox();
    box.add(Box.createHorizontalGlue());
    box.add(new JButton(closeMe));
    box.add(Box.createHorizontalStrut(20));
    cp.add(box, BorderLayout.SOUTH);

    cp.setBackground(Color.LIGHT_GRAY);

    Dimension d = window.getSize();
    ++d.width;
    window.setSize(d);

}

From source file:com.anrisoftware.prefdialog.core.AbstractTitleField.java

private void setupContainer() {
    Container container = getContainer();
    container.removeAll();
    container.setLayout(layout);//from ww w . j a  va  2  s  .c  om
    container.add(titleLabel, "0, 0");
    container.add(getComponent(), "0, 1");
}

From source file:fr.duminy.components.swing.form.JFormPane.java

/**
 * Add this form to a the given parent container. <strong>All parent components will be removed</strong> before adding this form to it.
 *
 * @param formContainer The new parent container for this form.
 *//*  w w w . j  ava2  s  .c  om*/
public void addTo(Container formContainer) {
    formContainer.removeAll();
    formContainer.add(this, BorderLayout.CENTER);
    formContainer.revalidate();
}

From source file:cn.pholance.datamanager.common.components.JRViewer.java

/**
*///from   w ww  . j  ava  2  s.c om
private void emptyContainer(Container container) {
    Component[] components = container.getComponents();

    if (components != null) {
        for (int i = 0; i < components.length; i++) {
            if (components[i] instanceof Container) {
                emptyContainer((Container) components[i]);
            }
        }
    }

    components = null;
    container.removeAll();
    container = null;
}

From source file:ireport_5_6_0.view.JRViewer.java

/**
 *///from w  w  w . ja v a  2s. c o m
private void emptyContainer(Container container) {
    Component[] components = container.getComponents();

    if (components != null) {
        for (int i = 0; i < components.length; i++) {
            if (components[i] instanceof Container) {
                emptyContainer((Container) components[i]);
            }
        }
    }
    components = null;
    container.removeAll();
    container = null;
}

From source file:edu.harvard.i2b2.analysis.ui.ExplorerC.java

public void PerformMiniVisualization(java.awt.Container poAwtContainer, String result, boolean writeFile) {
    try {/*from   w  ww  .j  a  v  a 2s.co m*/
        poAwtContainer.removeAll();

        log.info("Got to PerformMiniVisualization");
        record record1 = new record();
        poAwtContainer.add(record1);
        record1.start();
        if (writeFile) {
            record1.init();
        } else {
            record1.init(result);
        }
        theRecord = record1;
    } catch (Exception e) {
        log.error("done");
    }
}

From source file:edu.harvard.i2b2.analysis.ui.ExplorerC.java

@SuppressWarnings("deprecation")
public void DestroyMiniVisualization(java.awt.Container poAwtContainer) {
    try {/*from   w ww.  j  a  v  a 2  s .  c  om*/
        if (p != null) {
            p.stop();
            p.setVisible(false);
            p = null;
        }
        if (visualizationQueryThread != null) {
            visualizationQueryThread.stop();
            visualizationQueryThread = null;
        }
        if (oConnection != null) {
            oConnection = null;
        }
        log.debug("got to destroy");
        theRecord.removeAll();
        theRecord = null;
        poAwtContainer.removeAll();
    } catch (Exception e) {
        // log.error("done");
    }
}