本文整理匯總了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);
}
}
示例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);
}
}
}
示例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);
}
示例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();
}
示例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);
}
示例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;
}
示例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);
}
}
}
示例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);
}
};
}
示例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;
}
示例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();
}
示例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);
}
示例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();
}
示例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);
}
}
}
示例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);
}
示例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);
}
}
}