Search in sources :

Example 36 with Component

use of java.awt.Component in project ats-framework by Axway.

the class SwingElementFinder method find.

public static <T extends Component> T find(Robot robot, Container root, GenericTypeMatcher<T> m) {
    ComponentHierarchy hierarchy = robot.hierarchy();
    List<Component> found = null;
    if (root == null) {
        found = find(hierarchy, m);
    } else {
        found = find(new SingleComponentHierarchy(root, hierarchy), m);
    }
    if (found.isEmpty()) {
        throw componentNotFound(robot, hierarchy, m);
    }
    if (found.size() > 1) {
        throw multipleComponentsFound(found, m);
    }
    Component component = found.iterator().next();
    return m.supportedType().cast(component);
}
Also used : SingleComponentHierarchy(org.fest.swing.hierarchy.SingleComponentHierarchy) ComponentHierarchy(org.fest.swing.hierarchy.ComponentHierarchy) SingleComponentHierarchy(org.fest.swing.hierarchy.SingleComponentHierarchy) Component(java.awt.Component)

Example 37 with Component

use of java.awt.Component in project ats-framework by Axway.

the class SwingElementFinder method menuItemWithPath.

public static JMenuItemFixture menuItemWithPath(Robot robot, Container root, String... path) {
    ComponentMatcher m = new JMenuItemMatcher(path);
    Component item = robot.finder().find(root, m);
    assertThat(item).as(format(item)).isInstanceOf(JMenuItem.class);
    return new JMenuItemFixture(robot, (JMenuItem) item);
}
Also used : JMenuItemMatcher(org.fest.swing.driver.JMenuItemMatcher) JMenuItemFixture(org.fest.swing.fixture.JMenuItemFixture) ComponentMatcher(org.fest.swing.core.ComponentMatcher) Component(java.awt.Component)

Example 38 with Component

use of java.awt.Component in project zaproxy by zaproxy.

the class ExtensionKeyboard method initAllMenuItems.

private void initAllMenuItems(JMenu menu) {
    for (Component c : menu.getMenuComponents()) {
        if (c instanceof ZapMenuItem) {
            this.registerMenuItem((ZapMenuItem) c);
        } else if (c instanceof JMenu) {
            initAllMenuItems((JMenu) c);
        } else if (c instanceof JMenuItem) {
            JMenuItem menuItem = (JMenuItem) c;
            logger.debug("Unable to set accelerators on menu " + menuItem.getText());
        }
    }
}
Also used : ZapMenuItem(org.zaproxy.zap.view.ZapMenuItem) Component(java.awt.Component) JMenuItem(javax.swing.JMenuItem) JMenu(javax.swing.JMenu)

Example 39 with Component

use of java.awt.Component in project zaproxy by zaproxy.

the class ExtensionKeyboard method addAllMenuItems.

private void addAllMenuItems(List<KeyboardShortcut> kss, JMenu menu, boolean reset) {
    for (Component c : menu.getMenuComponents()) {
        if (c instanceof ZapMenuItem) {
            kss.add(menuToShortcut((ZapMenuItem) c, reset));
        } else if (c instanceof JMenu) {
            addAllMenuItems(kss, (JMenu) c, reset);
        } else if (c instanceof JMenuItem) {
            JMenuItem menuItem = (JMenuItem) c;
            logger.debug("Unable to set accelerators on menu " + menuItem.getText());
        }
    }
}
Also used : ZapMenuItem(org.zaproxy.zap.view.ZapMenuItem) Component(java.awt.Component) JMenuItem(javax.swing.JMenuItem) JMenu(javax.swing.JMenu)

Example 40 with Component

use of java.awt.Component in project intellij-community by JetBrains.

the class RadBoxLayoutManager method createSnapshotLayout.

@Override
public void createSnapshotLayout(final SnapshotContext context, final JComponent parent, final RadContainer container, final LayoutManager layout) {
    int rowCount = 1;
    int colCount = 1;
    boolean hasFiller = false;
    // workaround for lack of BoxLayout.getAxis()
    if (parent.getComponentCount() > 1) {
        for (Component component : parent.getComponents()) {
            if (component instanceof Box.Filler) {
                hasFiller = true;
            }
        }
        Rectangle bounds1 = parent.getComponent(0).getBounds();
        Rectangle bounds2 = parent.getComponent(1).getBounds();
        if (bounds2.x >= bounds1.x + bounds1.width) {
            colCount = parent.getComponentCount();
            if (!hasFiller)
                colCount++;
            myHorizontal = true;
        } else {
            rowCount = parent.getComponentCount();
            if (!hasFiller)
                rowCount++;
        }
    }
    container.setLayout(new GridLayoutManager(rowCount, colCount));
    if (!hasFiller) {
        if (myHorizontal) {
            container.addComponent(new RadHSpacer(context.newId(), colCount - 1));
        } else {
            container.addComponent(new RadVSpacer(context.newId(), rowCount - 1));
        }
    }
}
Also used : GridLayoutManager(com.intellij.uiDesigner.core.GridLayoutManager) Rectangle(java.awt.Rectangle) Component(java.awt.Component)

Aggregations

Component (java.awt.Component)645 JComponent (javax.swing.JComponent)163 Dimension (java.awt.Dimension)81 JLabel (javax.swing.JLabel)65 JPanel (javax.swing.JPanel)60 Insets (java.awt.Insets)55 Point (java.awt.Point)55 TableCellRenderer (javax.swing.table.TableCellRenderer)47 Container (java.awt.Container)46 JScrollPane (javax.swing.JScrollPane)42 JTable (javax.swing.JTable)36 JButton (javax.swing.JButton)35 BorderLayout (java.awt.BorderLayout)34 GridBagConstraints (java.awt.GridBagConstraints)34 JTextComponent (javax.swing.text.JTextComponent)34 GridBagLayout (java.awt.GridBagLayout)33 Color (java.awt.Color)32 JList (javax.swing.JList)31 TableColumn (javax.swing.table.TableColumn)31 MouseEvent (java.awt.event.MouseEvent)27