javax.swing.JComponent#getComponents ( )源码实例Demo

下面列出了javax.swing.JComponent#getComponents ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: open-ig   文件: GUIUtils.java
/**
  * Returns a set of all components under the given parent.
  * @param parent the parent
  * @return the set of components
  */
 public static Set<JComponent> allComponents(JComponent parent) {
 	Set<JComponent> result = new HashSet<>();
 	Deque<JComponent> queue = new LinkedList<>();
 	queue.add(parent);
 	while (!queue.isEmpty()) {
 		JComponent c = queue.removeFirst();
 		result.add(c);
for (Component c0 : c.getComponents()) {
	if (c0 instanceof JComponent) {
		queue.add((JComponent)c0);
	}
}
 	}
 	result.remove(parent);
 	return result;
 }
 
源代码2 项目: visualvm   文件: PluggableTreeTableView.java
private static void checkVisibility(JComponent comp) {
    if (comp == null) return;

    comp.invalidate();
    comp.revalidate();
    comp.doLayout();
    comp.repaint();

    for (Component c : comp.getComponents())
        if (c.isVisible()) {
            comp.setVisible(true);

            return;
        }

    comp.setVisible(false);
}
 
源代码3 项目: netbeans   文件: RunAnalysisPanel.java
void started() {
    started = true;
    
    ((CardLayout) progress.getLayout()).show(progress, "progress");
    progress.invalidate();

    //disable all elements in the dialog:
    List<JComponent> todo = new LinkedList<JComponent>();

    todo.add(this);

    while (!todo.isEmpty()) {
        JComponent c = todo.remove(0);

        if (c == progress) continue;

        c.setEnabled(false);

        for (Component child : c.getComponents()) {
            if (child instanceof JComponent) todo.add((JComponent) child);
        }
    }
}
 
源代码4 项目: dragonwell8_jdk   文件: ColorChooserPanel.java
/**
 * Allows to show context popup for all components recursively.
 *
 * @param component  the root component of the tree
 * @param value      whether or not the popup menu is inherited
 */
private static void setInheritsPopupMenu(JComponent component, boolean value) {
    component.setInheritsPopupMenu(value);
    for (Object object : component.getComponents()) {
        if (object instanceof JComponent) {
            setInheritsPopupMenu((JComponent) object, value);
        }
    }
}
 
源代码5 项目: pumpernickel   文件: ControlGridLayout.java
@Override
public int getBaseline(JComponent c, int width, int height) {
	Map<Component, Rectangle> blueprint = ControlGridLayout.this
			.createBlueprint(c);

	for (Component child : c.getComponents()) {
		Rectangle r = blueprint.get(child);
		if (r != null) {
			int y = child.getBaseline(r.width, r.height);
			return y + r.y;
		}
	}

	return super.getBaseline(c, width, height);
}
 
源代码6 项目: jdk8u60   文件: ColorChooserPanel.java
/**
 * Allows to show context popup for all components recursively.
 *
 * @param component  the root component of the tree
 * @param value      whether or not the popup menu is inherited
 */
private static void setInheritsPopupMenu(JComponent component, boolean value) {
    component.setInheritsPopupMenu(value);
    for (Object object : component.getComponents()) {
        if (object instanceof JComponent) {
            setInheritsPopupMenu((JComponent) object, value);
        }
    }
}
 
源代码7 项目: openjdk-8-source   文件: ColorChooserPanel.java
/**
 * Allows to show context popup for all components recursively.
 *
 * @param component  the root component of the tree
 * @param value      whether or not the popup menu is inherited
 */
private static void setInheritsPopupMenu(JComponent component, boolean value) {
    component.setInheritsPopupMenu(value);
    for (Object object : component.getComponents()) {
        if (object instanceof JComponent) {
            setInheritsPopupMenu((JComponent) object, value);
        }
    }
}
 
源代码8 项目: jdk8u-jdk   文件: ColorChooserPanel.java
/**
 * Allows to show context popup for all components recursively.
 *
 * @param component  the root component of the tree
 * @param value      whether or not the popup menu is inherited
 */
private static void setInheritsPopupMenu(JComponent component, boolean value) {
    component.setInheritsPopupMenu(value);
    for (Object object : component.getComponents()) {
        if (object instanceof JComponent) {
            setInheritsPopupMenu((JComponent) object, value);
        }
    }
}
 
源代码9 项目: jdk8u_jdk   文件: ColorChooserPanel.java
/**
 * Allows to show context popup for all components recursively.
 *
 * @param component  the root component of the tree
 * @param value      whether or not the popup menu is inherited
 */
private static void setInheritsPopupMenu(JComponent component, boolean value) {
    component.setInheritsPopupMenu(value);
    for (Object object : component.getComponents()) {
        if (object instanceof JComponent) {
            setInheritsPopupMenu((JComponent) object, value);
        }
    }
}
 
源代码10 项目: pumpernickel   文件: AnimatedLayout.java
@Override
protected void uninstall(JComponent parent) {
	super.uninstall(parent);
	ContainerListener l = (ContainerListener) parent
			.getClientProperty(PROPERTY_CONTAINER_LISTENER);
	parent.putClientProperty(PROPERTY_CONTAINER_LISTENER, null);
	parent.removeContainerListener(l);
	for (Component c : parent.getComponents()) {
		((JComponent) c).putClientProperty(
				"animatedLayout.propertyListener", null);
		((JComponent) c).removePropertyChangeListener(
				PROPERTY_DESTINATION, destinationListener);
	}
}
 
源代码11 项目: openjdk-jdk8u-backup   文件: ColorChooserPanel.java
/**
 * Allows to show context popup for all components recursively.
 *
 * @param component  the root component of the tree
 * @param value      whether or not the popup menu is inherited
 */
private static void setInheritsPopupMenu(JComponent component, boolean value) {
    component.setInheritsPopupMenu(value);
    for (Object object : component.getComponents()) {
        if (object instanceof JComponent) {
            setInheritsPopupMenu((JComponent) object, value);
        }
    }
}
 
源代码12 项目: pumpernickel   文件: AnimatingInspectorPanel.java
/**
 * Set double buffering for a component and all of its descendants.
 */
private static void setDoubleBuffered(JComponent jc, boolean b) {
	jc.setDoubleBuffered(b);
	for (Component c : jc.getComponents()) {
		if (c instanceof JComponent)
			setDoubleBuffered((JComponent) c, b);
	}
}
 
源代码13 项目: Bytecoder   文件: ColorChooserPanel.java
/**
 * Allows to show context popup for all components recursively.
 *
 * @param component  the root component of the tree
 * @param value      whether or not the popup menu is inherited
 */
private static void setInheritsPopupMenu(JComponent component, boolean value) {
    component.setInheritsPopupMenu(value);
    for (Object object : component.getComponents()) {
        if (object instanceof JComponent) {
            setInheritsPopupMenu((JComponent) object, value);
        }
    }
}
 
源代码14 项目: openjdk-jdk9   文件: ColorChooserPanel.java
/**
 * Allows to show context popup for all components recursively.
 *
 * @param component  the root component of the tree
 * @param value      whether or not the popup menu is inherited
 */
private static void setInheritsPopupMenu(JComponent component, boolean value) {
    component.setInheritsPopupMenu(value);
    for (Object object : component.getComponents()) {
        if (object instanceof JComponent) {
            setInheritsPopupMenu((JComponent) object, value);
        }
    }
}
 
源代码15 项目: jdk8u-jdk   文件: ColorChooserPanel.java
/**
 * Allows to show context popup for all components recursively.
 *
 * @param component  the root component of the tree
 * @param value      whether or not the popup menu is inherited
 */
private static void setInheritsPopupMenu(JComponent component, boolean value) {
    component.setInheritsPopupMenu(value);
    for (Object object : component.getComponents()) {
        if (object instanceof JComponent) {
            setInheritsPopupMenu((JComponent) object, value);
        }
    }
}
 
源代码16 项目: Astrosoft   文件: UIUtil.java
public static void setPanelBackground(JComponent panel, Color color) {
	if (panel!=null){
		panel.setBackground(color);
		for (Component c : panel.getComponents()) {
			if (c instanceof JPanel) {
				setPanelBackground((JPanel) c, color);
			}
		}
	}	
}
 
源代码17 项目: audiveris   文件: Board.java
/**
 * Convenient method to empty all the text fields of a given JComponent.
 *
 * @param component the component to "blank".
 */
public static void emptyFields (JComponent component)
{
    for (Component comp : component.getComponents()) {
        if (comp instanceof JTextField) {
            ((JTextComponent) comp).setText("");
        }
    }
}
 
源代码18 项目: Java8CN   文件: ColorChooserPanel.java
/**
 * Allows to show context popup for all components recursively.
 *
 * @param component  the root component of the tree
 * @param value      whether or not the popup menu is inherited
 */
private static void setInheritsPopupMenu(JComponent component, boolean value) {
    component.setInheritsPopupMenu(value);
    for (Object object : component.getComponents()) {
        if (object instanceof JComponent) {
            setInheritsPopupMenu((JComponent) object, value);
        }
    }
}
 
源代码19 项目: pentaho-reporting   文件: ComponentDrawable.java
/**
 * Prepares the component for drawing. This recursively disables the double-buffering as this would interfere with the
 * drawing.
 *
 * @param c
 *          the component that should be prepared.
 */
private void prepareComponent( final Component c ) {
  if ( c instanceof JComponent ) {
    final JComponent jc = (JComponent) c;
    jc.setDoubleBuffered( false );
    final Component[] childs = jc.getComponents();
    for ( int i = 0; i < childs.length; i++ ) {
      final Component child = childs[i];
      prepareComponent( child );
    }
  }
}
 
源代码20 项目: netbeans   文件: MarginViewportUI.java
public void installUI(JComponent c) {
    super.installUI(c);

    //Fetch the "no properties" string - it's not going to change
    //for the life of the session
    //        noPropsString = NbBundle.getMessage(MarginViewportUI.class,
    //            "CTL_NoProperties"); //NOI18N
    //Set an appropriate font and color.  Only really relevant on OS-X to
    //keep the font consistent with other NB fonts
    Color fg = UIManager.getColor("controlShadow"); //NOI18N

    if (fg == null) {
        fg = Color.LIGHT_GRAY;
    }

    c.setForeground(fg);

    Color bg = UIManager.getColor("Tree.background"); //NOI18N

    if (bg == null) {
        bg = Color.WHITE;
    }

    c.setBackground(bg);

    Font f = UIManager.getFont("Tree.font"); //NOI18N

    if (f == null) {
        f = UIManager.getFont("controlFont"); //NOI18N
    }

    if (f != null) {
        c.setFont(f);
    }

    c.addContainerListener(this);

    Component[] kids = c.getComponents();

    for (int i = 0; i < kids.length; i++) {
        //Should almost always be empty anyway, if not only one component,
        //but for completeness...
        kids[i].addComponentListener(this);
    }
}