List of usage examples for java.awt Container getComponents
public Component[] getComponents()
From source file:org.eclipse.wb.internal.swing.utils.SwingImageUtils.java
private static void fetchMenuVisualData_items(MenuVisualData menuData, Container menuObject) { menuData.m_itemBounds = Lists.newArrayList(); for (Component menuComponent : menuObject.getComponents()) { menuData.m_itemBounds.add(CoordinateUtils.get(menuComponent.getBounds())); }/*from w ww .jav a 2 s. c o m*/ }
From source file:org.eclipse.wb.internal.swing.utils.SwingScreenshotMaker.java
/** * Fix for {@link JLabel} with "html" as text. *//*from w w w.j a v a 2 s .c o m*/ private static void fixJLabelWithHTML(Component component) throws Exception { if (component instanceof JLabel) { JLabel label = (JLabel) component; String text = label.getText(); if (StringUtils.containsIgnoreCase(text, "<html>")) { SwingImageUtils.createComponentShotAWT(component); } } // process children if (component instanceof Container) { Container container = (Container) component; for (Component childComponent : container.getComponents()) { fixJLabelWithHTML(childComponent); } } }
From source file:org.eclipse.wb.tests.designer.core.model.association.InvocationSecondaryAssociationTest.java
public void test_0() throws Exception { setFileContentSrc("test/AFrame.java", getTestSource("public class AFrame extends JFrame {", " protected void addGB(Container parent, Component child, String constraints) {", " parent.add(child, constraints);", " }", "}")); setFileContentSrc("test/AFrame.wbp-component.xml", getSourceDQ("<?xml version='1.0' encoding='UTF-8'?>", "<component xmlns='http://www.eclipse.org/wb/WBPComponent'>", " <methods>", " <method name='addGB'>", " <parameter type='java.awt.Container' parent2='true'/>", " <parameter type='java.awt.Component' child2='true'/>", " <parameter type='java.lang.String'/>", " </method>", " </methods>", "</component>")); waitForAutoBuild();// ww w. j a v a 2s . co m // ContainerInfo frame = parseContainer("public class Test extends AFrame {", " public Test() {", " addGB(getContentPane(), new JButton('north'), BorderLayout.NORTH);", " addGB(getContentPane(), new JButton('west'), BorderLayout.WEST);", " }", "}"); frame.refresh(); // prepare contentPane with BorderLayout assertEquals(1, frame.getChildrenComponents().size()); ContainerInfo contentPane = (ContainerInfo) frame.getChildrenComponents().get(0); BorderLayout borderLayout = (BorderLayout) contentPane.getContainer().getLayout(); // check children of contentPane assertEquals(2, contentPane.getChildrenComponents().size()); { Container container = contentPane.getContainer(); Component[] components = container.getComponents(); assertEquals(2, components.length); } // check "button north" { ComponentInfo button = contentPane.getChildrenComponents().get(0); assertSame(BorderLayout.NORTH, borderLayout.getConstraints(button.getComponent())); } // check "button west" { ComponentInfo button = contentPane.getChildrenComponents().get(1); assertSame(BorderLayout.WEST, borderLayout.getConstraints(button.getComponent())); } // check association for "button" { ComponentInfo button = contentPane.getChildrenComponents().get(0); InvocationSecondaryAssociation association = (InvocationSecondaryAssociation) button.getAssociation(); assertEquals("addGB(getContentPane(), new JButton(\"north\"), BorderLayout.NORTH)", association.getSource()); assertEquals("addGB(getContentPane(), new JButton(\"north\"), BorderLayout.NORTH);", m_lastEditor.getSource(association.getStatement())); // can not be moved try { association.move(null); fail(); } catch (NotImplementedException e) { } // can not be reparented try { association.setParent(null); fail(); } catch (NotImplementedException e) { } } }
From source file:org.esa.nest.dat.views.polarview.PolarCanvas.java
private static void paintComponents(Container c, Graphics g) { if (!c.isShowing()) return;/* w w w . j a va 2 s .c o m*/ final int ncomponents = c.getComponentCount(); final Rectangle clip = g.getClipBounds(); int i = ncomponents - 1; while (i >= 0) { final Component component[] = c.getComponents(); final Component comp = component[i]; if (comp == null || !comp.isVisible()) continue; final Rectangle bounds = comp.getBounds(); Rectangle cr; if (clip == null) cr = new Rectangle(bounds); else cr = bounds.intersection(clip); if (cr.isEmpty()) continue; final Graphics cg = g.create(); cg.setClip(cr); cg.translate(bounds.x, bounds.y); try { comp.paint(cg); } catch (Throwable e) { // } cg.dispose(); i--; } }
From source file:org.jas.dnd.Jdk6u10TransparencyManager.java
private void doTheDoubleBuffer(Component c) { if (c instanceof JComponent) { JComponent comp = (JComponent) c; comp.setDoubleBuffered(false);//w w w . j a v a 2 s .c om } if (c instanceof Container) { Container container = (Container) c; for (Component c2 : container.getComponents()) { doTheDoubleBuffer(c2); } } }
From source file:org.objectstyle.cayenne.modeler.editor.SelectPropertiesPanel.java
public void setEnabled(boolean flag) { super.setEnabled(flag); // propagate to children Container mainPanel = (Container) getComponent(0); Component[] children = mainPanel.getComponents(); for (int i = 0; i < children.length; i++) { children[i].setEnabled(flag);// w w w .j a va 2 s .c o m } }
From source file:org.pentaho.reporting.tools.configeditor.ConfigDescriptionEditor.java
/** * A utility method to enable or disable a component and all childs. * * @param comp the component that should be enabled or disabled. * @param state the new enable state./*from w w w .ja va 2 s . c o m*/ */ private void deepEnable(final Component comp, final boolean state) { comp.setEnabled(state); if (comp instanceof Container) { final Container cont = (Container) comp; final Component[] childs = cont.getComponents(); for (int i = 0; i < childs.length; i++) { deepEnable(childs[i], state); } } }
From source file:org.pentaho.reporting.ui.datasources.kettle.EmbeddedKettleDataSourceDialog.java
/** * This method makes it possible to control any panel that gets rendered via XUL, without having to create hooks or * listeners into the XUL dialog. The presence of a query object dictates whether the panel should be enabled or * disabled.// w w w . ja va 2 s .c o m * * @param enable enable/disable the configuration panel * @param c */ private void setPanelEnabled(boolean enable, Component c) { if (null == c) { return; } Container container = null; if (c instanceof Container) { container = (Container) c; } if (container != null) { Component[] components = container.getComponents(); for (int i = 0; i < container.getComponentCount(); i++) { Component component = components[i]; setPanelEnabled(enable, component); } } c.setEnabled(enable); }