List of usage examples for javax.swing JComponent getComponentCount
public int getComponentCount()
From source file:Main.java
/** * Recursively remove all PropertyChangeListeners from a component * @param container//from w ww . j av a 2 s . com */ public static void removeAllPropertyChangeListeners(JComponent component) { if (component.getComponentCount() > 0) { for (Component child : component.getComponents()) { if (child instanceof JComponent) { removeAllPropertyChangeListeners((JComponent) child); } } } PropertyChangeListener[] tmpList = component.getPropertyChangeListeners(); for (PropertyChangeListener listener : tmpList) { component.removePropertyChangeListener(listener); } }
From source file:Main.java
/** * Remove all children from a JCompontent and remove all * PropertyChangeListeners for all children recursively. * * @param container//from w w w. j a v a 2 s . c o m */ public static void safeRemoveAll(JComponent container) { //remove all children PropertyChangeListeners if (container.getComponentCount() > 0) { for (Component child : container.getComponents()) { removeAllPropertyChangeListeners((JComponent) child); } } //remove all children container.removeAll(); }
From source file:Main.java
/** * @param fc/*from ww w .j av a 2 s .co m*/ * @param string */ private static void printComponentTree(final JComponent fc, final String string) { // c.setVisible(false); for (int i = 0; i < fc.getComponentCount(); i++) { final Component cc = fc.getComponent(i); System.out.println(string + "[" + i + "]" + cc.getClass().getSuperclass().getSimpleName() + ":" + cc + " Opaque: " + cc.isOpaque()); if (cc instanceof JComponent) { printComponentTree((JComponent) cc, string + "[" + i + "]"); } } }
From source file:Main.java
/** * Sets opacity of a component and all of its children. * Excludes JTextComponent./*from w ww. j ava 2 s . c o m*/ */ public static void setOpaqueDeep(JComponent component, boolean opaque) { if (!(component instanceof JTextComponent)) { component.setOpaque(opaque); for (int i = 0; i < component.getComponentCount(); i++) { Component c = component.getComponent(i); if (c instanceof JComponent) { setOpaqueDeep((JComponent) c, opaque); } } } }
From source file:Main.java
/** * Sets font of component and all of its children. * * @param component//from w w w .ja v a 2 s .c o m * component to modify * @param font * new font * @param childsOnly * whether exclude component from changes or not */ public static void setFontRecursively(final JComponent component, final Font font, final boolean childsOnly) { if (!childsOnly) { component.setFont(font); } for (int i = 0; i < component.getComponentCount(); i++) { if (component.getComponent(i) instanceof JComponent) { setFontRecursively((JComponent) component.getComponent(i), font, false); } } }
From source file:Main.java
/** * Sets foreground color of component and all of its children. * * @param component component to modify * @param foreground new foreground color * @param childsOnly whether exclude component from changes or not *///from w w w . j a va 2 s . co m public static void setForegroundRecursively(final JComponent component, final Color foreground, final boolean childsOnly) { if (!childsOnly) { component.setForeground(foreground); } for (int i = 0; i < component.getComponentCount(); i++) { if (component.getComponent(i) instanceof JComponent) { setForegroundRecursively((JComponent) component.getComponent(i), foreground, false); } } }
From source file:Main.java
/** * Sets focusable state of component and all of its children. * * @param component/*from ww w . j a v a 2 s . com*/ * component to modify * @param focusable * whether component is focusable or not * @param childsOnly * whether exclude component from changes or not */ public static void setFocusableRecursively(final JComponent component, final boolean focusable, final boolean childsOnly) { if (!childsOnly) { component.setFocusable(focusable); } for (int i = 0; i < component.getComponentCount(); i++) { if (component.getComponent(i) instanceof JComponent) { setFocusableRecursively((JComponent) component.getComponent(i), focusable, false); } } }
From source file:op.tools.SYSTools.java
/** * luft rekursiv durch alle Kinder eines Containers und setzt deren Enabled Status auf * enabled.// w w w .ja v a 2 s .co m */ public static void setXEnabled(JComponent container, boolean enabled) { // Bei einer Combobox muss die Rekursion ebenfalls enden. // Sie besteht aus weiteren Unterkomponenten // "disabled" wird sie aber bereits hier. if (container.getComponentCount() == 0 || container instanceof JComboBox) { // Rekursionsanker container.setEnabled(enabled); } else { Component[] c = container.getComponents(); for (int i = 0; i < c.length; i++) { if (c[i] instanceof JComponent) { JComponent jc = (JComponent) c[i]; setXEnabled(jc, enabled); } } } }
From source file:op.tools.SYSTools.java
/** * luft rekursiv durch alle Kinder eines Containers und entfernt evtl. vorhandene Listener. *//*w w w . ja v a2 s . c o m*/ public static void unregisterListeners(JComponent container) { if (container == null) { return; } removeListeners(container); if (container.getComponentCount() > 0) { Component[] c = container.getComponents(); for (int i = 0; i < c.length; i++) { if (c[i] instanceof JComponent) { unregisterListeners((JComponent) c[i]); } } } }
From source file:org.nuclos.client.genericobject.GenericObjectCollectController.java
private void collectComponents(JComponent comp, List<JComponent> lst) { for (Component c : comp.getComponents()) if (c instanceof JComponent) { JComponent jc = (JComponent) c; if (jc.getComponentCount() == 0) lst.add(jc);//ww w . j a va 2s . c o m if (jc instanceof LabeledComponent) { lst.add(jc); continue; } collectComponents(jc, lst); } }