Example usage for java.awt.event ContainerEvent getChild

List of usage examples for java.awt.event ContainerEvent getChild

Introduction

In this page you can find the example usage for java.awt.event ContainerEvent getChild.

Prototype

public Component getChild() 

Source Link

Document

Returns the component that was affected by the event.

Usage

From source file:Main.java

public static void main(String[] a) {
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JPanel buttonPanel = new JPanel();
    buttonPanel.addContainerListener(new ContainerListener() {
        public void componentAdded(ContainerEvent e) {
            displayMessage(" added to ", e);
        }/*w w w  . j  a v a2  s. c  om*/

        public void componentRemoved(ContainerEvent e) {
            displayMessage(" removed from ", e);
        }

        void displayMessage(String action, ContainerEvent e) {
            System.out.println(((JButton) e.getChild()).getText() + " was" + action
                    + e.getContainer().getClass().getName());
        }
    });
    buttonPanel.add(new JButton("A"));

    frame.add(buttonPanel);

    frame.setSize(300, 200);
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] a) {
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JPanel buttonPanel = new JPanel(true);
    buttonPanel.addContainerListener(new ContainerListener() {
        public void componentAdded(ContainerEvent e) {
            displayMessage(" added to ", e);
        }//w  w  w.  ja  va 2 s  .  co  m

        public void componentRemoved(ContainerEvent e) {
            displayMessage(" removed from ", e);
        }

        void displayMessage(String action, ContainerEvent e) {
            System.out.println(((JButton) e.getChild()).getText() + " was" + action
                    + e.getContainer().getClass().getName());
        }
    });
    buttonPanel.add(new JButton("A"));

    frame.add(buttonPanel);

    frame.setSize(300, 200);
    frame.setVisible(true);
}

From source file:UsingContainerListener.java

public static void main(String[] a) {
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JPanel buttonPanel = new JPanel();
    buttonPanel.addContainerListener(new ContainerListener() {

        public void componentAdded(ContainerEvent e) {
            displayMessage(" added to ", e);
        }/*from   w  w  w. j  a  va  2  s  . c om*/

        public void componentRemoved(ContainerEvent e) {
            displayMessage(" removed from ", e);
        }

        void displayMessage(String action, ContainerEvent e) {
            System.out.println(((JButton) e.getChild()).getText() + " was" + action
                    + e.getContainer().getClass().getName());
        }
    });
    buttonPanel.add(new JButton("A"));

    frame.add(buttonPanel);

    frame.setSize(300, 200);
    frame.setVisible(true);
}

From source file:Main.java

public static void main() {

    ContainerListener listener = new ContainerAdapter() {
        public void componentAdded(ContainerEvent evt) {

            Component c = evt.getChild();
        }/* w  ww  .  j ava  2s.  c o  m*/

        public void componentRemoved(ContainerEvent evt) {

            Component c = evt.getChild();
        }
    };

    JFrame frame = new JFrame();
    frame.addContainerListener(listener);
}

From source file:Main.java

public Main() {
    addContainerListener(new ContainerAdapter() {
        @Override//from  w  w w  .  j  a  va  2 s. c om
        public void componentAdded(ContainerEvent e) {
            if (jProgressBar1 == e.getChild()) {
                new Thread(new Task()).start();
            }
        }
    });
    jProgressBar1.setName("");
    jProgressBar1.setValue(0);
    jProgressBar1.setStringPainted(true);
    add(jProgressBar1);
}

From source file:com.qspin.qtaste.recorder.SpyInstaller.java

@Override
public synchronized void componentRemoved(ContainerEvent e) {
    super.componentRemoved(e);
    if (e.getChild() != null) {
        for (Spy s : e.getChild().getListeners(Spy.class)) {
            s.removeTarget(e.getChild());
        }/*from w w  w.  j  a v a 2 s.c o m*/
    }
}

From source file:ContainerEventDemo.java

void displayMessage(String action, ContainerEvent e) {
    display.append(((JButton) e.getChild()).getText() + " was" + action + e.getContainer().getClass().getName()
            + newline);/*  w  w  w.  j  av  a  2  s.c  o m*/
    display.setCaretPosition(display.getDocument().getLength());
}

From source file:org.eclipse.jubula.rc.swing.components.AUTSwingHierarchy.java

/**
 * Add the new component to the hierarchy.
 * {@inheritDoc}//w w w .  j av a2s  .  c om
 */
public void componentAdded(ContainerEvent event) {
    checkDispatchThread();
    addComponent(event.getChild());
}

From source file:org.eclipse.jubula.rc.swing.components.AUTSwingHierarchy.java

/**
 * Remove the removed component from the hierarchy.
 * {@inheritDoc}// ww w . j a  v  a 2  s .  c o  m
 */
public void componentRemoved(ContainerEvent event) {
    checkDispatchThread();
    removeComponent(event.getChild(), event.getContainer());
}

From source file:org.openestate.tool.helloworld.HelloWorldObjectViewPanel.java

@Override
protected void tabComponentAdded(ContainerEvent e) {
    super.tabComponentAdded(e);
    Component c = e.getChild();
    if (c instanceof AbstractTab) {
        ((AbstractTab) c).setViewPanel(this);
    }/*from   ww w .  j a va 2s. c  o  m*/
}