当前位置: 首页>>代码示例>>Java>>正文


Java Container.getComponents方法代码示例

本文整理汇总了Java中java.awt.Container.getComponents方法的典型用法代码示例。如果您正苦于以下问题:Java Container.getComponents方法的具体用法?Java Container.getComponents怎么用?Java Container.getComponents使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.awt.Container的用法示例。


在下文中一共展示了Container.getComponents方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: layoutContainer

import java.awt.Container; //导入方法依赖的package包/类
public void layoutContainer(final Container parent) {
    final Insets insets = parent.getInsets();
    int posX = insets.left;
    final int posY = insets.top;
    final int height = parent.getHeight() - insets.top - insets.bottom;

    for (Component comp : parent.getComponents()) {
        if (comp.isVisible()) {
            Dimension pref = comp.getPreferredSize();
            if (proportionalHeight) {
                int h = Math.min(pref.height, height);
                int o = (height - h) / 2;
                comp.setBounds(posX, posY + o, pref.width, h);
            } else {
                comp.setBounds(posX, posY, pref.width, height);
            }
            posX += hGap;
            posX += pref.width;
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:HorizontalLayout.java

示例2: findNotificationLabel

import java.awt.Container; //导入方法依赖的package包/类
private static JLabel findNotificationLabel (Container container) {
    for (Component component : container.getComponents ()) {
        if (component.getClass ().getName ().indexOf (NOTIFICATION_LABEL_NAME) != -1) {
            return (JLabel) component;
        }
        if (component instanceof JRootPane) {
            JRootPane rp = (JRootPane) component;
            return findNotificationLabel (rp.getContentPane ());
        }
        if (component instanceof JPanel) {
            JPanel p = (JPanel) component;
            return findNotificationLabel (p);
        }
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:NotificationLineSupportTest.java

示例3: layoutContainer

import java.awt.Container; //导入方法依赖的package包/类
public void layoutContainer(final Container parent) {
    final Insets insets = parent.getInsets();
    final int posX = insets.left;
    int posY = insets.top;
    final int width = parent.getWidth() - insets.left - insets.right;

    for (Component comp : parent.getComponents()) {
        if (comp.isVisible()) {
            Dimension pref = comp.getPreferredSize();
            if (proportionalWidth) {
                int w = Math.min(pref.width, width);
                int o = (width - w) / 2;
                comp.setBounds(posX, posY + o, w, pref.height);
            } else {
                comp.setBounds(posX, posY, width, pref.height);
            }
            pref.height += vGap;
            posY += pref.height;
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:VerticalLayout.java

示例4: find

import java.awt.Container; //导入方法依赖的package包/类
private static Component find(Component c, Class<?> clazz, boolean fail) {
    if (clazz.isInstance(c)) {
        return c;
    }
    if (c instanceof Container) {
        Container cont = (Container)c;
        for (Component p : cont.getComponents()) {
            Component r = find(p, clazz, false);
            if (r != null) {
                return r;
            }
        }
    }
    if (fail) {
        fail("Not found " + clazz + " in children of " + c);
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:TemplatesPanelGUITest.java

示例5: findComponent

import java.awt.Container; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public static <T> T findComponent(Container container, Class<T> componentClass, int depth) {
    if (depth > 0) {
        for (Component c : container.getComponents()) {
            if (componentClass.isAssignableFrom(c.getClass())) {
                return (T) c;
            } else if (c instanceof Container) {
                T target = findComponent((Container) c, componentClass, depth - 1);
                if (target != null) {
                    return target;
                }
            }
        }
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:SearchNbEditorKit.java

示例6: preferredLayoutSize

import java.awt.Container; //导入方法依赖的package包/类
public Dimension preferredLayoutSize(final Container parent) {
    final Insets insets = parent.getInsets();
    final Dimension d = new Dimension(insets.left + insets.right,
                                      insets.top + insets.bottom);
    int maxWidth = 0;
    int visibleCount = 0;

    for (Component comp : parent.getComponents()) {
        if (comp.isVisible()) {
            final Dimension size = comp.getPreferredSize();
            maxWidth = Math.max(maxWidth, size.width);
            d.height += size.height;
            visibleCount++;
        }
    }

    d.height += (visibleCount - 1) * vGap;
    d.width += maxWidth;

    return d;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:VerticalLayout.java

示例7: evalSize

import java.awt.Container; //导入方法依赖的package包/类
private Dimension evalSize(Container parent, boolean min) {
	synchronized (parent.getTreeLock()) {
		int w = 0, h = 0;
		int nrows = 1, ncols = 1;
		int row = 0, col = 0;
		// eval max size and rows/cols
		for (Component cmp : parent.getComponents())
			if (cmp.isVisible()) {
				ncols = col + 1;
				if (row >= nrows)
					nrows = row + 1;
				// eval size
				Dimension d = min ? cmp.getMinimumSize() : cmp
						.getPreferredSize();
				if (w < d.width)
					w = d.width;
				if (h < d.height)
					h = d.height;
				// eval matrix
				if (++row >= getRows()) {
					row = 0;
					col++;
				}
			}
		// add insets
		Insets insets = parent.getInsets();
		return new Dimension(insets.left + insets.right + ncols * w
				+ (ncols - 1) * getHgap(), insets.top + insets.bottom
				+ nrows * h + (nrows - 1) * getVgap());
	}
}
 
开发者ID:KeepTheBeats,项目名称:alevin-svn2,代码行数:32,代码来源:MyGridLayout.java

示例8: enableComponent

import java.awt.Container; //导入方法依赖的package包/类
public static void enableComponent(Container con, boolean state, Component component) {
    for (Component c : con.getComponents()) {
        if (c instanceof Container) {
            enableComponent((Container) c, state, component);
        }
        if (component != null && component.equals(c)) {
            continue;
        }
        if (c instanceof JLabel) {
            c.setVisible(state);
        } else {
            c.setEnabled(state);
        }
    }
}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:16,代码来源:Utility.java

示例9: getIndexOfComponentInParent

import java.awt.Container; //导入方法依赖的package包/类
private int getIndexOfComponentInParent(Component component) {
    Container parent = component.getParent();
    if (parent == null) {
        return -1;
    }
    Component[] components = parent.getComponents();
    for (int i = 0; i < components.length; i++) {
        if (components[i] == component) {
            return i;
        }
    }
    return -1;
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:14,代码来源:GeneralSiblingSelector.java

示例10: layoutContainer

import java.awt.Container; //导入方法依赖的package包/类
public void layoutContainer(Container c) {
    Insets insets = c.getInsets();
    int height = yInset + insets.top;

    Component[] children = c.getComponents();
    Dimension compSize = null;
    for (Component child : children) {
        compSize = child.getPreferredSize();
        child.setSize(compSize.width, compSize.height);
        child.setLocation(xInset + insets.left, height);
        height += compSize.height + yGap;
    }

}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:15,代码来源:MetalworksPrefs.java

示例11: detachFromHierarchyOf

import java.awt.Container; //导入方法依赖的package包/类
private void detachFromHierarchyOf(Container container) {
    container.removeContainerListener(this);
    Component[] components = container.getComponents();
    for (int i = 0; i < components.length; i++) {
        detachFrom(components[i]); // Will callback recursively any nested JPanels
    }
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:8,代码来源:GenericListener.java

示例12: getFrames

import java.awt.Container; //导入方法依赖的package包/类
/**
 * Adds all {@code JEditorPanes} under {@code container} tagged by {@code
 * FrameEditorPaneTag} to the {@code list}. It adds only top
 * level {@code JEditorPanes}.  For instance if there is a frame
 * inside the frame it will return the top frame only.
 *
 * @param c the container to find all frames under
 * @param list {@code List} to append the results too
 */
private static void getFrames(final Container container, List<JEditorPane> list) {
    for (Component c : container.getComponents()) {
        if (c instanceof FrameEditorPaneTag
            && c instanceof JEditorPane ) { //it should be always JEditorPane
            list.add((JEditorPane) c);
        } else {
            if (c instanceof Container) {
                getFrames((Container) c, list);
            }
        }
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:22,代码来源:TextComponentPrintable.java

示例13: layoutContainer

import java.awt.Container; //导入方法依赖的package包/类
@Override
public void layoutContainer(Container parent) {
    StyledDocument doc = (StyledDocument)editor.getDocument();
    for (Component comp : parent.getComponents()) {
        Position pos = positions.get(comp);
        int line = findLineNumber(doc, pos.getOffset());
        Dimension prefSize = comp.getPreferredSize();
        int dy = lineHeight() - prefSize.height;
        dy = dy > 0 ? dy / 2 + 1 : 0;
        comp.setBounds(LEFT_GAP,
                       line * lineHeight() + dy,
                       parent.getWidth() - LEFT_GAP - RIGHT_GAP,
                       Math.min(prefSize.height, lineHeight()));
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:16,代码来源:CustomCodeView.java

示例14: handleMouseOver

import java.awt.Container; //导入方法依赖的package包/类
private void handleMouseOver( Container c, MouseListener ml ) {
    c.addMouseListener(ml);
    for( Component child : c.getComponents() ) {
        child.addMouseListener(ml);
        if( child instanceof Container )
            handleMouseOver((Container)child, ml);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:BalloonManager.java

示例15: show

import java.awt.Container; //导入方法依赖的package包/类
public static void show(Container container, String indent) {
    out((container.isShowing() ? "[[ " : "") + indent + container.getClass().getName()); // NOI18N
    Component[] children = container.getComponents();

    for (Component child : children) {
        if (child instanceof Container) {
            show((Container) child, "    " + indent); // NOI18N
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:UI.java


注:本文中的java.awt.Container.getComponents方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。