當前位置: 首頁>>代碼示例>>Java>>正文


Java Container類代碼示例

本文整理匯總了Java中java.awt.Container的典型用法代碼示例。如果您正苦於以下問題:Java Container類的具體用法?Java Container怎麽用?Java Container使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Container類屬於java.awt包,在下文中一共展示了Container類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: enumerateCycle

import java.awt.Container; //導入依賴的package包/類
private void enumerateCycle(Container container, List<Component> cycle) {
    if (!(container.isVisible() && container.isDisplayable())) {
        return;
    }

    cycle.add(container);

    Component[] components = container.getComponents();
    for (Component comp : components) {
        if (comp instanceof Container) {
            Container cont = (Container)comp;

            if (!cont.isFocusCycleRoot() &&
                !cont.isFocusTraversalPolicyProvider() &&
                !((cont instanceof JComponent) && ((JComponent)cont).isManagingFocus()))
            {
                enumerateCycle(cont, cycle);
                continue;
            }
        }
        cycle.add(comp);
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:24,代碼來源:SortingFocusTraversalPolicy.java

示例2: addTree

import java.awt.Container; //導入依賴的package包/類
private void addTree(Collection<Long> order, Set<Long> set, Container cont) {
    for (int i = 0; i < cont.getComponentCount(); i++) {
        Component comp = cont.getComponent(i);
        Object peer = AWTAccessor.getComponentAccessor().getPeer(comp);
        if (peer instanceof XComponentPeer) {
            Long window = Long.valueOf(((XComponentPeer)peer).getWindow());
            if (!set.contains(window)) {
                set.add(window);
                order.add(window);
            }
        } else if (comp instanceof Container) {
            // It is lightweight container, it might contain heavyweight components attached to this
            // peer
            addTree(order, set, (Container)comp);
        }
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:18,代碼來源:XComponentPeer.java

示例3: removeProjectTab

import java.awt.Container; //導入依賴的package包/類
@Override
public void removeProjectTab(ProjectWindowTab projectWindowTab) {

	DefaultMutableTreeNode node = this.getTreeNode(projectWindowTab.getTitle());
	if (node != null) {
		DefaultMutableTreeNode pareNode = (DefaultMutableTreeNode) node.getParent();
		pareNode.remove(node);
	}

	JComponent component = projectWindowTab.getJComponentForVisualization();
	Container container = component.getParent();
	if (container != null) {
		container.remove(component);
	}
	this.tabVector.remove(projectWindowTab);

	this.getTreeModel().reload();
	this.projectTreeExpand2Level(3, true);
}
 
開發者ID:EnFlexIT,項目名稱:AgentWorkbench,代碼行數:20,代碼來源:ProjectWindow.java

示例4: setViewer

import java.awt.Container; //導入依賴的package包/類
@SuppressWarnings({ "unchecked", "rawtypes" })
protected void setViewer(LayerViewer vv) {
	if (this.vv == vv)
		return;
	this.vv = vv;
	Container contentPane = satellite.getContentPane();

	if (satelliteViewer != null)
		contentPane.remove(satelliteViewer);
	if (vv != null) {
		satelliteViewer = new MySatelliteVisualizationViewer(vv,
				new Dimension(100, 100));

		satelliteViewer.getRenderContext().setVertexFillPaintTransformer(
				vv.getRenderContext().getVertexFillPaintTransformer());

		vv.addChangeListener(satelliteViewer);

		contentPane.add(satelliteViewer);
	} else {
		satelliteViewer = null;
	}
	satellite.pack();
	autoZoomSatellite();
}
 
開發者ID:KeepTheBeats,項目名稱:alevin-svn2,代碼行數:26,代碼來源:SatelliteViewerCorner.java

示例5: init

import java.awt.Container; //導入依賴的package包/類
private static void init(Container container) {
    container.setLayout(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.fill = GridBagConstraints.BOTH;
    gbc.gridx = 0;
    gbc.gridy = 1;
    JLabel label = new JLabel();
    Dimension size = new Dimension(111, 0);
    label.setPreferredSize(size);
    label.setMinimumSize(size);
    container.add(label, gbc);
    gbc.gridx = 1;
    gbc.weightx = 1;
    container.add(new JScrollBar(JScrollBar.HORIZONTAL, 1, 111, 1, 1111), gbc);
    gbc.gridx = 2;
    gbc.gridy = 0;
    gbc.weightx = 0;
    gbc.weighty = 1;
    container.add(new JScrollBar(JScrollBar.VERTICAL, 1, 111, 1, 1111), gbc);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:21,代碼來源:Test8039464.java

示例6: findButton

import java.awt.Container; //導入依賴的package包/類
private static JButton findButton(Component comp) {

        if (comp instanceof JButton) {
            return (JButton) comp;
        }

        if (comp instanceof Container) {
            Container cont = (Container) comp;
            for (int i = 0; i < cont.getComponentCount(); i++) {
                JButton result = findButton(cont.getComponent(i));
                if (result != null) {
                    return result;
                }
            }
        }
        return null;
    }
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:18,代碼來源:bug6219960.java

示例7: addTree

import java.awt.Container; //導入依賴的package包/類
private void addTree(Collection order, Set set, Container cont) {
    for (int i = 0; i < cont.getComponentCount(); i++) {
        Component comp = cont.getComponent(i);
        ComponentPeer peer = comp.getPeer();
        if (peer instanceof XComponentPeer) {
            Long window = Long.valueOf(((XComponentPeer)peer).getWindow());
            if (!set.contains(window)) {
                set.add(window);
                order.add(window);
            }
        } else if (comp instanceof Container) {
            // It is lightweight container, it might contain heavyweight components attached to this
            // peer
            addTree(order, set, (Container)comp);
        }
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:18,代碼來源:XComponentPeer.java

示例8: createSeparator

import java.awt.Container; //導入依賴的package包/類
protected Container createSeparator() {
    return new JPanel() {

        public Dimension getPreferredSize() {
            return new Dimension(10, 2);
        }

        public void paint(Graphics g) {
            int width = getWidth();
            g.setColor(Color.darkGray);
            g.drawLine(0, 0, width, 0);
            g.setColor(Color.white);
            g.drawLine(0, 1, width, 1);
        }
    };
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:17,代碼來源:MotifOptionPaneUI.java

示例9: found

import java.awt.Container; //導入依賴的package包/類
protected List<IJavaElement> found(List<IJavaElement> pElements, IJavaAgent driver) {
    List<IJavaElement> r = new ArrayList<IJavaElement>();
    for (IJavaElement je : pElements) {
        Component component = je.getComponent();
        if (!(component instanceof Container)) {
            continue;
        }
        int index = getIndexOfComponentInParent(component);
        if (index < 0) {
            continue;
        }
        Container parent = component.getParent();
        JWindow topContainer = driver.switchTo().getTopContainer();
        for (int i = index + 1; i < parent.getComponentCount(); i++) {
            Component c = parent.getComponent(i);
            IJavaElement je2 = JavaElementFactory.createElement(c, driver, driver.switchTo().getTopContainer());
            if (sibling.matchesSelector(je2).size() > 0) {
                IJavaElement e = topContainer.addElement(JavaElementFactory.createElement(c, driver, topContainer));
                if (!r.contains(e)) {
                    r.add(e);
                }
            }
        }
    }
    return r;
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:27,代碼來源:GeneralSiblingSelector.java

示例10: JDesktopPane

import java.awt.Container; //導入依賴的package包/類
/**
 * Creates a new <code>JDesktopPane</code>.
 */
public JDesktopPane() {
    setUIProperty("opaque", Boolean.TRUE);
    setFocusCycleRoot(true);

    setFocusTraversalPolicy(new LayoutFocusTraversalPolicy() {
        public Component getDefaultComponent(Container c) {
            JInternalFrame jifArray[] = getAllFrames();
            Component comp = null;
            for (JInternalFrame jif : jifArray) {
                comp = jif.getFocusTraversalPolicy().getDefaultComponent(jif);
                if (comp != null) {
                    break;
                }
            }
            return comp;
        }
    });
    updateUI();
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:23,代碼來源:JDesktopPane.java

示例11: layoutContainer

import java.awt.Container; //導入依賴的package包/類
@Override
public void layoutContainer(Container container) {
  ComponentElement parent = (ComponentElement) container;
  CssStyleDeclaration style = ((ComponentElement) parent).getComputedStyle();

  float scale = parent.getOwnerDocument().getSettings().getScale();
  float containingBoxWidth = container.getWidth() / scale;

  float left = style.getPx(CssProperty.BORDER_LEFT_WIDTH, containingBoxWidth) + 
      style.getPx(CssProperty.PADDING_LEFT, containingBoxWidth);
  float top = style.getPx(CssProperty.BORDER_TOP_WIDTH, containingBoxWidth) + 
      style.getPx(CssProperty.PADDING_TOP, containingBoxWidth);
  float right = style.getPx(CssProperty.BORDER_RIGHT_WIDTH, containingBoxWidth) + 
      style.getPx(CssProperty.PADDING_RIGHT, containingBoxWidth);
  
  layout.layout(parent, left, top, container.getWidth() - left - right, false);
}
 
開發者ID:stefanhaustein,項目名稱:nativehtml,代碼行數:18,代碼來源:SwingLayoutAdapter.java

示例12: requestFocus

import java.awt.Container; //導入依賴的package包/類
private static void requestFocus(final JEditorPane editorPane) {
    if (!SwingUtilities.isEventDispatchThread()) {
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                requestFocus(editorPane);
            }
        });
        return ;
    }
    Container p = editorPane;
    while ((p = p.getParent()) != null) {
        if (p instanceof TopComponent) {
            ((TopComponent) p).requestActive();
            break;
        }
    }
    editorPane.requestFocusInWindow();
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:20,代碼來源:MethodChooser.java

示例13: main

import java.awt.Container; //導入依賴的package包/類
public static void main(String[] args) throws IntrospectionException {
    Class[] types = {
            Component.class,
            Container.class,
            JComponent.class,
            AbstractButton.class,
            JButton.class,
            JToggleButton.class,
    };
    // Control set. "enabled" and "name" has the same pattern and can be found
    String[] names = {
            "enabled",
            "name",
            "focusable",
    };
    for (String name : names) {
        for (Class type : types) {
            BeanUtils.getPropertyDescriptor(type, name);
        }
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:22,代碼來源:Test4619792.java

示例14: RoutingInfoWindow

import java.awt.Container; //導入依賴的package包/類
public RoutingInfoWindow(DTNHost host) {
	this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
	this.host = host;
	Container cp = this.getContentPane();
	this.setLayout(new BorderLayout());
	
	this.treePane = new JScrollPane();
	updateTree();
	
	cp.add(treePane, BorderLayout.NORTH);
	
	this.refreshButton = new JButton("refresh");
	this.refreshButton.addActionListener(this);
	cp.add(refreshButton, BorderLayout.SOUTH);
	
	this.pack();		
	this.setVisible(true);
}
 
開發者ID:MaX121,項目名稱:Bachelor-Thesis,代碼行數:19,代碼來源:RoutingInfoWindow.java

示例15: setButtonState

import java.awt.Container; //導入依賴的package包/類
static void setButtonState(Container c, String buttonString, boolean flag) {
	int len = c.getComponentCount();
	for (int i = 0; i < len; i++) {
		Component comp = c.getComponent(i);

		if (comp instanceof JButton) {
			JButton b = (JButton) comp;

			if (buttonString.equals(b.getText())) {
				b.setEnabled(flag);
			}

		} else if (comp instanceof Container) {
			setButtonState((Container) comp, buttonString, flag);
		}
	}
}
 
開發者ID:SensorsINI,項目名稱:jaer,代碼行數:18,代碼來源:SingleOrStereoCameraCalibration.java


注:本文中的java.awt.Container類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。