Example usage for java.awt Container getParent

List of usage examples for java.awt Container getParent

Introduction

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

Prototype

public Container getParent() 

Source Link

Document

Gets the parent of this component.

Usage

From source file:org.jdal.swing.form.FormFocusTransversalPolicy.java

@Override
public Component getComponentAfter(Container container, Component component) {

    // Fix awt bug looking for ComboBoxEditor instead ComboBox
    // see http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6205817
    if (component.getParent() instanceof JComboBox)
        component = component.getParent();

    int index = components.indexOf(component);

    if (index == -1) { // not owner
        Container childContainer = getTopmostProvider(container, component);
        if (childContainer == null)
            return getFirstComponent(container);

        FocusTraversalPolicy ftp = childContainer.getFocusTraversalPolicy();
        if (ftp != null && ftp != this) {
            Component next = ftp.getComponentAfter(childContainer, component);
            if (next != ftp.getFirstComponent(container))
                return next;

            // child cycle
            do {//from w  w w.j  a va  2 s.c  o  m
                index = components.indexOf(childContainer);
                childContainer = childContainer.getParent();
            } while (index == -1 || childContainer == null);

            if (index == -1) {
                log.warn("I can't figure what is the next component");
                return getFirstComponent(container);
            }
        }
    }

    index++;

    if (index < components.size() && index >= 0) {
        Component c = getComponent(index);
        if (c.isEnabled() && c.isFocusable())
            return c;
        else
            return getComponentAfter(container, c);
    }

    return getFirstComponent(container);
}

From source file:org.jdal.swing.form.FormFocusTransversalPolicy.java

Container getTopmostProvider(Container focusCycleRoot, Component aComponent) {
    Container aCont = aComponent.getParent();
    Container ftp = null;/*from  w ww  .j  a v  a 2 s  .com*/
    while (aCont != focusCycleRoot && aCont != null) {
        if (aCont.isFocusTraversalPolicyProvider()) {
            ftp = aCont;
        }
        aCont = aCont.getParent();
    }
    if (aCont == null) {
        return null;
    }
    return ftp;
}

From source file:org.jimcat.gui.perspective.boards.cards.Card.java

/**
 * //from www. j a  va 2  s  .c o  m
 * get the grand parent of a card
 * 
 * @return the grandParent Container
 */
private Container getCardGrandParent() {
    Container parent = this.getParent();
    if (parent != null) {
        return parent.getParent();
    }
    return null;
}

From source file:org.openmicroscopy.shoola.agents.metadata.editor.PropertiesUI.java

/**
 * Returns the <code>JXTaskPane</code> hosting the component.
 * /* ww w . j  a  va 2s .  c  om*/
 * @param parent The value to check.
 * @return See above.
 */
private Container getComponent(Container parent) {
    if (parent == null)
        return null;
    if (parent instanceof JXTaskPane)
        return parent;
    return getComponent(parent.getParent());
}

From source file:pt.lsts.neptus.plugins.sunfish.awareness.SituationAwareness.java

@Override
public void setActive(boolean mode, StateRenderer2D source) {
    super.setActive(mode, source);
    Container parent = source.getParent();
    while (parent != null && !(parent.getLayout() instanceof BorderLayout))
        parent = parent.getParent();
    if (mode) {/*ww w . ja v  a2 s  . com*/
        JPanel panel = new JPanel(new BorderLayout());
        panel.add(slider, BorderLayout.CENTER);
        panel.add(minTimeLabel, BorderLayout.WEST);
        panel.add(maxTimeLabel, BorderLayout.EAST);
        parent.add(panel, BorderLayout.SOUTH);
    } else {
        parent = slider.getParent().getParent();
        parent.remove(slider.getParent());
    }
    parent.invalidate();
    parent.validate();
    parent.repaint();

}

From source file:ro.nextreports.designer.util.TableUtil.java

/**
 * Creats a row header for the given table. The row number is displayed to
 * the left of the table ( starting with row 1).
 *
 * @param table       the table to create the row header for
 * @param headerWidth the number of characters to size the header
 *//*from  w ww .ja va  2 s. com*/
public static TableRowHeader setRowHeader(JTable table, int headerWidth) {
    TableRowHeader result = null;
    Container p = table.getParent();
    if (p instanceof JViewport) {
        Container gp = p.getParent();
        if (gp instanceof JScrollPane) {
            JScrollPane scrollPane = (JScrollPane) gp;
            result = new TableRowHeader(table);
            scrollPane.setRowHeaderView(result);
        }
    }
    return result;
}

From source file:ro.nextreports.designer.util.TableUtil.java

/**
 * Creates row header for table with row number (starting with 1) displayed.
 *///w w  w.  jav a2s. co m
public static void removeRowHeader(JTable table) {
    Container p = table.getParent();
    if (p instanceof JViewport) {
        Container gp = p.getParent();
        if (gp instanceof JScrollPane) {
            JScrollPane scrollPane = (JScrollPane) gp;
            scrollPane.setRowHeader(null);
        }
    }
}

From source file:tauargus.gui.PanelTable.java

private JFrame getParentFrame() {
    Container container = this;
    while (!(container instanceof JFrame)) {
        container = container.getParent();
    }/*  ww  w. j  a  v  a2  s. c o m*/
    return (JFrame) container;
}