List of usage examples for java.awt Container getComponent
public Component getComponent(int n)
From source file:Main.java
public static void disableNewFolderButton(Container c) { int len = c.getComponentCount(); for (int i = 0; i < len; i++) { Component comp = c.getComponent(i); if (comp instanceof JButton) { JButton b = (JButton) comp; Icon icon = b.getIcon(); if (icon != null && icon == UIManager.getIcon("FileChooser.newFolderIcon")) b.setEnabled(false);/*from w ww . j a va 2s.c o m*/ } else if (comp instanceof Container) { disableNewFolderButton((Container) comp); } } }
From source file:Main.java
protected static SpringLayout.Constraints getConstraintsForCell(int row, int col, Container parent, int cols) { SpringLayout layout = (SpringLayout) parent.getLayout(); Component c = parent.getComponent(row * cols + col); return layout.getConstraints(c); }
From source file:Main.java
private static JTextField getTexField(Container container) { for (int i = 0; i < container.getComponentCount(); i++) { Component child = container.getComponent(i); if (child instanceof JTextField) { return (JTextField) child; } else if (child instanceof Container) { JTextField field = getTexField((Container) child); if (field != null) { return field; }// www . j a va 2 s . c om } } return null; }
From source file:Main.java
public static int getIndex(Container parent, Component child) { for (int i = 0; i < parent.getComponentCount(); i++) { if (child.equals(parent.getComponent(i))) return i; }/*from w ww. ja v a2 s. com*/ return -1; }
From source file:Util.java
public static final Component getVisibleChildAt(Container container, Point p) { for (int i = 0; i < container.getComponentCount(); i++) { Component c = container.getComponent(i); if (c.isVisible() && c.contains(p.x - c.getX(), p.y - c.getY())) return c; }/*from w ww . j a v a 2 s . co m*/ return null; }
From source file:Main.java
/** * Returns the index of the given component in the given container. * * @param c the Component to look for//from www . j a v a 2 s . com * @param container the parent container, where this component is added * @return the index of the component in the container or -1 if no such * component is contained in the container */ public static int getComponentIndex(Component c, Container container) { for (int i = 0, count = container.getComponentCount(); i < count; i++) { if (container.getComponent(i).equals(c)) return i; } return -1; }
From source file:Main.java
public static final int getComponentIndex(final Component component) { if (component != null && component.getParent() != null) { final Container c = component.getParent(); for (int i = 0; i < c.getComponentCount(); i++) { if (c.getComponent(i) == component) { return i; }/* ww w. ja v a 2 s . c o m*/ } } return -1; }
From source file:Main.java
/** * Finds the index of a component in its parent container by iterating over * all children.//from w w w. j ava 2s .co m * @param component the component must have a parent * @return -1 if component is null or has no parent */ public static final int getComponentIndex(Component component) { if (component != null && component.getParent() != null) { Container c = component.getParent(); for (int i = 0; i < c.getComponentCount(); i++) { if (c.getComponent(i) == component) { return i; } } } return -1; }
From source file:Main.java
public static int getVisibleChildrenCount(Component c) { if (c == null || !(c instanceof Container)) return 0; int count = 0; Container container = (Container) c; for (int i = 0; i < container.getComponentCount(); i++) if (container.getComponent(i).isVisible()) count++;//from w w w.j a va 2 s.c o m return count; }
From source file:Main.java
public static void setEnabledForChildren(final Container container, final boolean bEnabled) { for (int i = 0; i < container.getComponentCount(); i++) { final Component child = container.getComponent(i); child.setEnabled(bEnabled);//from w w w .ja va2 s . co m } }