public class ComponentSelector

  1. Object
  2. ComponentSelector

ImplementsCollection<Component>, Iterable<Component>, Set<Component>

A tool to facilitate selection and manipulation of UI components as sets. This uses fluent API style, similar to jQuery to make it easy to find UI components and modify them as groups.

Set Selection

Sets of components can either be created by explicitly adding components to the set, or by providing a “selector” string that specifies how the set should be formed. Some examples:

  • $("Label") - The set of all components on the current form with UIID=“Label”

  • $("#AddressField") - The set of components with name=“AddressField”

  • $("TextField#AddressField") - The set of components with UIID=TextField and Name=AddressField

  • $("Label, Button") - Set of components in current form with UIID=“Label” or UIID=“Button”

  • $("Label", myContainer) - Set of labels within the container myContainer

  • $("MyContainer *") - All descendants of the container with UIID=“MyContainer”. Will not include “MyContainer”.

  • $("MyContainer > *") - All children of of the container with UIID=“MyContainer”.

  • $("MyContainer > Label) - All children with UIID=Label of container with UIID=MyContainer

  • $("Label").getParent() - All parent components of labels in the current form.

Tags

To make selection more flexible, you can “tag” components so that they can be easily targeted by a selector. You can add tags to components using #addTags(java.lang.String...), and remove them using #removeTags(java.lang.String...). Once you have tagged a component, it can be targeted quite easily using a selector. Tags are specified in a selector with a . prefix. E.g.:

  • $(".my-tag") - The set of all components with tag “my-tag”.

  • $("Label.my-tag") - The set of all components with tag “my-tag” and UIID=“Label”

  • $("Label.my-tag.myother-tag") - The set of all components with tags “my-tag” and “myother-tag” and UIID=“Label”. Matches only components that include all of those tags.

Modifying Components in Set

While component selection alone in the ComponentSelector is quite powerful, the true power comes when you start to operate on the entire set of components using the Fluent API of ComponentSelector. ComponentSelector includes wrapper methods for most of the mutator methods of Component, Container, and a few other common component types.

For example, the following two snippets are equivalent:

`for (Component c : $("Label")) {
    c.getStyle().setFgColor(0xff0000);`
}

and

`$("Label").setFgColor(0xff0000);`

The second snippet is clearly easier to type and more compact. But we can take it further. The Fluent API style allows you to chain together multiple method calls. This even makes it desirable to operate on single-element sets. E.g.:

`Button myButton = $(new Button("Some text"))
.setUIID("Label")
.addTags("cell", "row-"+rowNum, "col-"+colNum, rowNum%2==0 ? "even":"odd")
.putClientProperty("row", rowNum)
.putClientProperty("col", colNum)
.asComponent(Button.class);`

The above snippet wraps a new Button in a ComponentSelector, then uses the fluent API to apply several properties to the button, before using #asComponent() to return the Button itself.

API Overview

ComponentSelector includes a few different types of methods:

  • Wrapper methods for Component, Container, etc… to operate on all applicable components in the set.

  • Component Tree Traversal Methods to return other sets of components based on the current set. E.g. #find(java.lang.String), #getParent(), #getComponentAt(int), #closest(java.lang.String), #nextSibling(), #prevSibling(), #parents(java.lang.String), #getComponentForm(), and many more.

  • Effects. E.g. #fadeIn(), #fadeOut(), #slideDown(), #slideUp(), #animateLayout(int), #animateHierarchy(int), etc..

  • Convenience methods to help with common tasks. E.g. #$(java.lang.Runnable) as a short-hand for Display#callSerially(java.lang.Runnable)

  • Methods to implement java.util.Set because ComponentSelector is a set.

Effects

The following is an example form that demonstrates the use of ComponentSelector to easily create effects on components in a form.

    private void showEffectsForm() {
        Form f = new Form("Effects", new BorderLayout());
        applyToolbar(f);
        Button fadeInFadeOut = $(new Button("Fade"))
                .setIcon(FontImage.MATERIAL_BLUR_ON, 4)
                .addActionListener(e->{
                    $(e).getParent().find(">*").fadeOutAndWait(1000).fadeInAndWait(1000);
                })
                .asComponent(Button.class);


        Button slideUp = $(new Button("Slide Up"))
                .setIcon(FontImage.MATERIAL_EXPAND_LESS)
                .addActionListener(e->{
                    $(e).getParent().find(">*").slideUpAndWait(1000).slideDownAndWait(1000);
                })
                .asComponent(Button.class);


        Button replace = $(new Button("Replace Fade/Slide"))
                .setIcon(FontImage.MATERIAL_REDEEM)
                .addActionListener(e->{
                    $(e).getParent()
                            .find(">*")
                            .replaceAndWait(c->{
                                return $(new Label("Replacement"))
                                        .putClientProperty("origComponent", c)
                                        .asComponent();
                            }, CommonTransitions.createFade(1000))
                            .replaceAndWait(c->{
                                Component orig = (Component)c.getClientProperty("origComponent");
                                if (orig != null) {
                                    c.putClientProperty("origComponent", null);
                                    return orig;
                                }
                                return c;

                            }, CommonTransitions.createCover(CommonTransitions.SLIDE_HORIZONTAL, false, 1000));


                })
                .asComponent(Button.class);


        Button replaceFlip = $(new Button("Replace Flip"))
                .setIcon(FontImage.MATERIAL_REDEEM)
                .addActionListener(e->{
                    $(e).getParent()
                            .find(">*")
                            .replaceAndWait(c->{
                                return $(new Label("Replacement"))
                                        .putClientProperty("origComponent", c)
                                        .asComponent();
                            },new FlipTransition(0xffffff, 1000))
                            .replaceAndWait(c->{
                                Component orig = (Component)c.getClientProperty("origComponent");
                                if (orig != null) {
                                    c.putClientProperty("origComponent", null);
                                    return orig;
                                }
                                return c;

                            },new FlipTransition(0xffffff, 1000));


                })
                .asComponent(Button.class);

        Container root = GridLayout.encloseIn(3, fadeInFadeOut, slideUp, replace, replaceFlip);
        f.addComponent(BorderLayout.CENTER, root);
        f.show();
    }

Advanced Use of Tags

The following shows the use of tags to help with striping a table, and selecting rows when clicked on.

    private void showTableDemo() {
        Form f = new Form("Table Demo", new BorderLayout());
        applyToolbar(f);
        CSVParser parser = new CSVParser();
        String[][] data = null;
        try {
            data =   parser.parse(Display.getInstance().getResourceAsStream(null, "/sample-data.csv"));
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        if (data== null) {
            ToastBar.showMessage("Failed to parse sample data", FontImage.MATERIAL_INFO);
            return;
        }
        int numRows = data.length;
        int numCols = data[0].length;
        TableLayout tl = new TableLayout(numRows, numCols);
        Container table = new Container(tl);
        int rowNum = 0;
        int colNum = 0;
        for (String[] row : data) {
            colNum = 0;
            for (String cell : row) {
                table.add(
                        tl.createConstraint(rowNum, colNum),
                        $(new Button(cell))
                                .setUIID("Label")
                                .addTags("cell", "row-"+rowNum, "col-"+colNum, rowNum%2==0 ? "even":"odd")
                                .putClientProperty("row", rowNum)
                                .putClientProperty("col", colNum)
                                .asComponent()

                );
                colNum++;
            }
            rowNum++;
        }


        $(".cell", table).setMargin(0).setPadding(0)
                .addActionListener(e->{
                    // Action listener in each cell so that we can highlight the
                    // selected row
                    Component cell = (Component)e.getSource();
                    int row = (int)cell.getClientProperty("row");
                    int col = (int)cell.getClientProperty("col");

                    // Restore the style of the previously selected row
                    // and remove the selected-row tag
                    $(e).getParent().find(">.selected-row")
                            .each(c->{
                                // Restore the old style that we stored when we made
                                // the row selected originally (see below)
                                c.setUnselectedStyle((Style)c.getClientProperty("default-style"));
                            })
                            .removeTags("selected-row")
                            .getParent()
                            .repaint();

                    // Now add the "selected-row" tag, and modify the styles
                    $(e).getParent().find(">.row-"+row).addTags("selected-row")
                            .each(c->{
                                // Store the existing style so that we can
                                // reapply it when the row becomes unselected
                                Style oldStyle = new Style(c.getStyle());
                                c.putClientProperty("default-style", oldStyle);
                            })
                            .setBgColor(0x89cff0)
                            .setFgColor(0xffffff)
                            .setBgTransparency(255)
                            .getParent()
                            .repaint();
                });

        // Add striping to the table  (make the even rows gray)
        $(".even", table)
            .setBgColor(0xcccccc)
            .setBgTransparency(255);




        f.addComponent(BorderLayout.CENTER, $(BoxLayout.encloseY(table)).setScrollableY(true).asComponent());

        f.show();
    }

See full Demo App in this Github Repo

Modifying Style Properties

Modifying styles deserves special mention because components have multiple Style objects associated with them. Component#getStyle() returns the style of the component in its current state. Component#getPressedStyle() gets the pressed style of the component, Component#getSelectedStyle() get its selected style, etc..

ComponentSelector wraps each of the getXXXStyle() methods of Component with corresponding methods that return proxy styles for all components in the set. #getStyle() returns a proxy Style that proxies all of the styles returned from each of the Component#getStyle() methods in the set. #getPressedStyle() returns a proxy for all of the pressed styles, etc..

Example Modifying Text Color of All Buttons in a container when they are pressed only

`Style pressed = $("Button", myContainer).getPressedStyle();
pressed.setFgColor(0xff0000);`

A slightly more elegant pattern would be to use the #selectPressedStyle() method to set the default style for mutations to “pressed”. Then we could use the fluent API of ComponentSelector to chain multiple style mutations. E.g.:

`$("Button", myContainer)
    .selectPressedStyle()
    .setFgColor(0xffffff)
    .setBgColor(0x0)
    .setBgTransparency(255);`

A short-hand for this would be to add the :pressed pseudo-class to the selector. E.g.

`$("Button:pressed", myContainer)
    .setFgColor(0xffffff)
    .setBgColor(0x0)
    .setBgTransparency(255);`

The following style pseudo-classes are supported:

  • :pressed - Same as calling #selectPressedStyle()

  • :selected - Same as calling #selectSelectedStyle()

  • :unselected - Same as calling #selectUnselectedStyle()

  • :all - Same as calling #selectAllStyles()

  • :* - Alias for :all

  • :disabled - Same as calling #selectDisabledStyle()

You can chain calls to selectedXXXStyle(), enabling to chain together mutations of multiple different style properties. E.g To change the pressed foreground color, and then change the selected foreground color, you could do:

`$("Button", myContainer)
   .selectPressedStyle()
   .setFgColor(0x0000ff)
   .selectSelectedStyle()
   .setFgColor(0x00ff00);`

Filtering Sets

There are many ways to remove components from a set. Obviously you can use the standard java.util.Set methods to explicitly remove components from your set:

`ComponentSelector sel = $("Button").remove(myButton, true);
    // The set of all buttons on the current form, except myButton`

or

`ComponentSelector sel = $("Button").removeAll($(".some-tag"), true);
   // The set of all buttons that do NOT contain the tag ".some-tag"`

You could also use the #filter(com.codename1.ui.ComponentSelector.Filter) to explicitly declare which elements should be kept, and which should be discarded:

`ComponentSelector sel = $("Button").filter(c->{
    return c.isVisible();`);
    // The set of all buttons that are currently visible.
}

Tree Navigation

One powerful aspect of working with sets of components is that you can generate very specific sets of components using very simple queries. Consider the following queries:

  • $(myButton1, myButton2).getParent() - The set of parents of myButton1 and myButton2. If they have the same parent, then this set will only contain a single element: the common parent container. If they have different parents, then this set will include both parent containers.

  • $(myButton).getParent().find(">TextField") - The set of siblings of myButton that have UIID=TextField

  • $(myButton).closest(".some-tag") - The set containing the “nearest” parent container of myButton that has the tag “.some-tag”. If there are no matching components, then this will be an empty set. This is formed by crawling up the tree until it finds a matching component. Works the same as jQuery’s closest() method.

  • $(".my-tag").getComponentAt(4) - The set of 5th child components of containers with tag “.my-tag”.

Nested types

interface ComponentSelector.ComponentClosureInterface used for providing callbacks that receive a Component as input.
interface ComponentSelector.ComponentMapperInterface used by #map(com.codename1.ui.ComponentSelector.ComponentMapper) to form a new set of components based on the components in one set.
interface ComponentSelector.FilterInterface used by #filter(com.codename1.ui.ComponentSelector.Filter) to form a new set of components based on the components in one set.

Constructors

public ComponentSelector(Component... cmps)Creates a component selector that wraps the provided components.
public ComponentSelector(Set<Component> cmps)Creates a component selector that wraps the provided components.
public ComponentSelector(String selector)Creates a selector that will query the current form.
public ComponentSelector(String selector, Component... roots)Creates a selector with the provided roots.
public ComponentSelector(String selector, Collection<Component> roots)Creates a selector with the provided roots.

Methods

public static ComponentSelector $(Component... cmps)Deprecated Wraps provided components in a ComponentSelector set.
public static ComponentSelector select(Component... cmps)Alias of #$(com.codename1.ui.Component...)
public static ComponentSelector $(ActionEvent e)Deprecated Creates a ComponentInspector with the source component of the provided event.
public static ComponentSelector select(ActionEvent e)Alias of #$(com.codename1.ui.events.ActionEvent)
public static ComponentSelector $(Runnable r)Deprecated Wraps Display#callSerially(java.lang.Runnable)
public static ComponentSelector select(Runnable r)Alias of #$(java.lang.Runnable)
public static ComponentSelector $(Set<Component> cmps)Deprecated Creates a new ComponentSelector with the provided set of components.
public static ComponentSelector select(Set<Component> cmps)Alias of #$(java.util.Set)
public static ComponentSelector $(String selector)Deprecated Creates a new ComponentSelector with the components matched by the provided selector.
public static ComponentSelector select(String selector)Alias of #$(java.lang.String)
public static ComponentSelector $(String selector, Component... roots)Deprecated Creates a ComponentSelector with the components matched by the provided selector in the provided roots’ subtrees.
public static ComponentSelector select(String selector, Component... roots)Alias of com.codename1.ui.Component...)
public static ComponentSelector $(String selector, Collection<Component> roots)Deprecated Creates a ComponentSelector with the components matched by the provided selector in the provided roots’ subtrees.
public static ComponentSelector select(String selector, Collection<Component> roots)Alias of java.util.Collection)
public ComponentSelector each(ComponentSelector.ComponentClosure closure)Applies the given callback to each component in the set.
public ComponentSelector map(ComponentSelector.ComponentMapper mapper)Creates a new set based on the elements of the current set and a mapping function which defines the elements that should be in the new set.
public ComponentSelector filter(ComponentSelector.Filter filter)Creates a new set of components formed by filtering the current set using a filter function.
public ComponentSelector filter(String selector)Filters the current found set against the given selector.
public ComponentSelector parent(String selector)Creates a new set of components consisting of all of the parents of components in this set.
public ComponentSelector parents(String selector)Creates new set of components consisting of all of the ancestors of components in this set which match the provided selector.
public ComponentSelector closest(String selector)Creates a new set of components consistng of all “closest” ancestors of components in this set which match the provided selector.
public ComponentSelector firstChild()Creates new set consisting of the first child of each component in the current set.
public ComponentSelector lastChild()Creates new set consisting of the last child of each component in the current set.
public ComponentSelector nextSibling()Creates set of “next” siblings of components in this set.
public ComponentSelector prevSibling()Creates set of “previous” siblings of components in this set.
public ComponentSelector animateStyle(Style destStyle, int duration, SuccessCallback<ComponentSelector> callback)Animates this set of components, replacing any modified style properties of the destination style to the components.
public ComponentSelector fadeIn()Fade in this set of components.
public ComponentSelector fadeIn(int duration)Fade in this set of components.
public ComponentSelector fadeIn(int duration, SuccessCallback<ComponentSelector> callback)Fade in this set of components.
public ComponentSelector fadeInAndWait()Fades in this component and blocks until animation is complete.
public ComponentSelector fadeInAndWait(int duration)Fades in this component and blocks until animation is complete.
public boolean isVisible()Returns true if the first component in this set is visible.
public ComponentSelector setVisible(boolean visible)Wrapper for Component#setVisible(boolean)
public boolean isHidden()Returns true if first component in this set is hidden.
public ComponentSelector setHidden(boolean b)Wraps Component#setHidden(boolean)
public ComponentSelector fadeOut()Fades out components in this set.
public ComponentSelector fadeOut(int duration)Fades out components in this set.
public ComponentSelector fadeOut(int duration, SuccessCallback<ComponentSelector> callback)Fades out components in this set.
public ComponentSelector slideUp(int duration)Hide the matched components with a sliding motion.
public ComponentSelector slideUp(int duration, SuccessCallback<ComponentSelector> callback)Hide the matched elements with a sliding motion.
public ComponentSelector slideUpAndWait(int duration)Hide the matched elements with a sliding motion.
public ComponentSelector slideDown()Display the matched elements with a sliding motion.
public ComponentSelector slideUp()Hide the matched elements with a sliding motion.
public ComponentSelector slideDown(int duration)Display the matched elements with a sliding motion.
public ComponentSelector slideDown(int duration, SuccessCallback<ComponentSelector> callback)Display the matched elements with a sliding motion.
public ComponentSelector slideDownAndWait(int duration)Display the matched elements with a sliding motion.
public ComponentSelector fadeOutAndWait(int duration)Hide the matched elements by fading them to transparent.
public ComponentSelector replace(ComponentSelector.ComponentMapper mapper)Replaces the matched components within respective parents with replacements defined by the provided mapper.
public ComponentSelector replace(ComponentSelector.ComponentMapper mapper, Transition t)Replaces the matched components within respective parents with replacements defined by the provided mapper.
public ComponentSelector replaceAndWait(ComponentSelector.ComponentMapper mapper, Transition t)Replaces the matched components within respective parents with replacements defined by the provided mapper.
public ComponentSelector find(String selector)Uses the results of this selector as the roots to create a new selector with the provided selector string.
public Iterator<Component> iterator()Returns the results of this selector.
public Style getStyle()Gets a proxy style that wraps the result of Component#getStyle() of each component in set.
public Style getStyle(Component component)Gets a style object for the given component that can be used to modify the component’s styles.
public Style getSelectedStyle()Returns a proxy style for all of the selected styles of the components in this set.
public ComponentSelector setSelectedStyle(Style style)Sets selected style of all components in found set.
public ComponentSelector selectSelectedStyle()Sets the current style to the selected style.
public ComponentSelector selectUnselectedStyle()Sets the current style to the unselected style.
public ComponentSelector selectPressedStyle()Sets the current style to the pressed style.
public ComponentSelector selectDisabledStyle()Sets the current style to the disabled style.
public ComponentSelector selectAllStyles()Sets the current style to each component’s ALL STYLES proxy style.
public Style getUnselectedStyle()Returns a proxy style for all of the unselected styles of the components in this set.
public ComponentSelector setUnselectedStyle(Style style)Sets unselected style of all components in found set.
public Style getPressedStyle()Returns a proxy style for all of the pressed styles of the components in this set.
public ComponentSelector setPressedStyle(Style style)Sets pressed style of all components in found set.
public Style getDisabledStyle()Returns a proxy style for all of the disabled styles of the components in this set.
public ComponentSelector setDisabledStyle(Style style)Sets disabled style of all components in found set.
public Style getAllStyles()Returns a proxy style for all of the “all” styles of the components in this set.
public int size()Returns number of results found.
public boolean isEmpty()Returns true if this set has no elements.
public boolean contains(Object o)Checks if an object is contained in result set.
public Object[] toArray()Returns results as an array.
public <T> T[] toArray(T[] a)Returns results as an array.
public boolean add(Component e)Explicitly adds a component to the result set.
public ComponentSelector append(Component child)Appends a child component to the first container in this set.
public ComponentSelector append(Object constraint, Component child)Appends a child component to the first container in this set.
public ComponentSelector append(ComponentSelector.ComponentMapper mapper)Append a child element to each container in this set.
public ComponentSelector append(Object constraint, ComponentSelector.ComponentMapper mapper)Append a child element to each container in this set.
public ComponentSelector add(Component e, boolean chain)Fluent API wrapper for #add(com.codename1.ui.Component)
public boolean remove(Object o)Explicitly removes a component from the result set.
public ComponentSelector remove(Object o, boolean chain)Fluent API wrapper for #remove(java.lang.Object).
public boolean containsAll(Collection<?> c)Checks if the result set contains all of the components found in the provided collection.
public boolean addAll(Collection<? extends Component> c)Adds all components in the given collection to the result set.
public ComponentSelector addAll(Collection<? extends Component> c, boolean chain)Fluent API wrapper for #addAll(java.util.Collection).
public Component asComponent()Returns the first component in this set.
public <T extends Component> T asComponent(Class<T> type)Returns the first component in this set.
public List<Component> asList()Returns the components of this set as a List.
public boolean retainAll(Collection<?> c)Retains only elements of the result set that are contained in the provided collection.
public ComponentSelector retainAll(Collection<?> c, boolean chain)Fluent API wrapper for #retainAll(java.util.Collection)
public boolean removeAll(Collection<?> c)Removes all of the components in the provided collection from the result set.
public ComponentSelector removeAll(Collection<?> c, boolean chain)Fluent API wrapper for #removeAll(java.util.Collection)
public void clear()Clears the result set.
public ComponentSelector clear(boolean chain)Fluent API wrapper for (@link #clear()}
public String toString()Returns a string representation of the object.
public ComponentSelector addTags(String... tags)Adds the given tags to all elements in the result set.
public ComponentSelector removeTags(String... tags)Removes the given tags from all elements in the result set.
public ComponentSelector getParent()Gets the set of all “parent” components of components in the result set.
public ComponentSelector setSameWidth()Wrapper for Component#setSameWidth(com.codename1.ui.Component...).
public ComponentSelector setSameHeight()Wrapper for Component#setSameHeight(com.codename1.ui.Component...).
public ComponentSelector clearClientProperties()Wrapper for Component#clearClientProperties().
public ComponentSelector putClientProperty(String key, Object value)Wrapper for java.lang.Object)
public Object getClientProperty(String key)Gets a client property from the first component in the set.
public ComponentSelector setDirtyRegion(Rectangle rect)Wrapper for Component#setDirtyRegion(com.codename1.ui.geom.Rectangle)
public ComponentSelector setX(int x)Wrapper for Component#setX(int)
public ComponentSelector setY(int y)Wrapper for Component#setY(int)
public ComponentSelector setWidth(int width)Wrapper for Component#setWidth(int)
public ComponentSelector setHeight(int height)Wrapper for Component#setHeight(int)
public ComponentSelector setPreferredSize(Dimension dim)Wrapper for Component#setPreferredSize(com.codename1.ui.geom.Dimension)
public ComponentSelector setPreferredH(int h)Wrapper for Component#setPreferredH(int)
public ComponentSelector setPreferredW(int w)Wrapper for Component#setPreferredW(int)
public ComponentSelector setScrollSize(Dimension size)Wrapper for Component#setScrollSize
public ComponentSelector setSize(Dimension size)Wrapper for Component#setSize(com.codename1.ui.geom.Dimension)
public ComponentSelector setUIID(String uiid)Wrapper for Component#setUIID(java.lang.String)
public ComponentSelector remove()Wrapper for Component#remove().
public ComponentSelector addFocusListener(FocusListener l)Adds a focus listener to all components in found set.
public ComponentSelector removeFocusListener(FocusListener l)Removes focus listener from all components in found set.
public ComponentSelector addScrollListener(ScrollListener l)Adds scroll listener to all components in found set.
public ComponentSelector removeScrollListener(ScrollListener l)Removes scroll listener from all components in found set.
public ComponentSelector setSelectCommandText(String text)Sets select command text on all components in found set.
public ComponentSelector setLabelForComponent(Label l)Wraps Component#setLabelForComponent(com.codename1.ui.Label)
public ComponentSelector paintBackgrounds(Graphics g)Wraps Component#paintBackgrounds(com.codename1.ui.Graphics)
public ComponentSelector paintComponent(Graphics g)Wraps Component#paintComponent(com.codename1.ui.Graphics)
public ComponentSelector paint(Graphics g)Wraps Component#paint(com.codename1.ui.Graphics)
public boolean contains(int x, int y)Returns true if any of the components in the found set contains the provided coordinate.
public ComponentSelector setFocusable(boolean focus)Sets all components in the found set focusability.
public ComponentSelector repaint()Wraps Component#repaint()
public ComponentSelector repaint(int x, int y, int w, int h)Wraps int, int, int)
public ComponentSelector setScrollAnimationSpeed(int speed)Wraps Component#setScrollAnimationSpeed(int)
public ComponentSelector setSmoothScrolling(boolean smooth)Wraps Component#setSmoothScrolling(boolean)
public ComponentSelector addDropListener(ActionListener l)Adds a drop listener to all components in found set.
public ComponentSelector removeDropListener(ActionListener l)Removes a drop listener from all components in found set.
public ComponentSelector addDragOverListener(ActionListener l)Adds drag over listener to all components in found set.
public ComponentSelector removeDragOverListener(ActionListener l)Removes drag over listener from all components in found set.
public ComponentSelector addPointerPressedListener(ActionListener l)Adds pointer pressed listener to all components in found set.
public ComponentSelector addLongPressListener(ActionListener l)Adds long pointer pressed listener to all components in found set.
public ComponentSelector removePointerPressedListener(ActionListener l)Removes pointer pressed listener from all components in found set.
public ComponentSelector removeLongPressListener(ActionListener l)Removes long pointer pressed listener from all components in found set.
public ComponentSelector addPointerReleasedListener(ActionListener l)Adds pointer released listener to all components in found set.
public ComponentSelector removePointerReleasedListener(ActionListener l)Removes pointer released listener from all components in found set.
public ComponentSelector addPointerDraggedListener(ActionListener l)Adds pointer dragged listener to all components in found set.
public ComponentSelector removePointerDraggedListener(ActionListener l)REmoves pointer dragged listener from all components in found set.
public ComponentSelector requestFocus()Wraps Component#requestFocus()
public ComponentSelector refreshTheme()Wraps Component#refreshTheme()
public ComponentSelector refreshTheme(boolean merge)Wraps Component#refreshTheme(boolean)
public ComponentSelector setCellRenderer(boolean cell)Wraps Component#setCellRenderer(boolean)
public ComponentSelector setScrollVisible(boolean vis)Wraps Component#setScrollVisible(boolean)
public ComponentSelector setEnabled(boolean enabled)Wraps Component#setEnabled(boolean)
public ComponentSelector setName(String name)Wraps Component#setName(java.lang.String)
public ComponentSelector setRTL(boolean rtl)Wraps Component#setRTL(boolean)
public ComponentSelector setTactileTouch(boolean t)Wraps Component#setTactileTouch(boolean)
public ComponentSelector setPropertyValue(String key, Object value)Wraps java.lang.Object)
public ComponentSelector paintLockRelease()Wraps Component#paintLockRelease()
public ComponentSelector setSnapToGrid(boolean s)Wraps Component#setSnapToGrid(boolean)
public boolean isIgnorePointerEvents()
public ComponentSelector setIgnorePointerEvents(boolean ignore)
public ComponentSelector setFlatten(boolean f)Wraps Component#setFlatten(boolean)
public ComponentSelector setTensileLength(int len)Wraps Component#setTensileLength(int)
public ComponentSelector setGrabsPointerEvents(boolean g)Wraps Component#setGrabsPointerEvents(boolean)
public ComponentSelector setScrollOpacityChangeSpeed(int scrollOpacityChangeSpeed)Wraps Component#setScrollOpacityChangeSpeed(int)
public ComponentSelector growShrink(int duration)Wraps Component#growShrink(int)
public ComponentSelector setDraggable(boolean draggable)Wraps Component#setDraggable(boolean)
public ComponentSelector setDropTarget(boolean target)Wraps Component#setDropTarget(boolean)
public ComponentSelector setHideInPortait(boolean hide)Wraps Component#setHideInPortrait(boolean)
public ComponentSelector setHidden(boolean b, boolean changeMargin)Wraps boolean)
public ComponentSelector setComponentState(Object state)Wraps Component#setComponentState(java.lang.Object)
public ComponentSelector setLeadComponent(Component lead)Wraps Container#setLeadComponent(com.codename1.ui.Component)
public ComponentSelector setLayout(Layout layout)Wraps Container#setLayout(com.codename1.ui.layouts.Layout)
public ComponentSelector invalidate()Wraps Container#invalidate()
public ComponentSelector setShouldCalcPreferredSize(boolean shouldCalcPreferredSize)Wraps Container#setShouldCalcPreferredSize(boolean)
public ComponentSelector applyRTL(boolean rtl)Wraps Container#applyRTL(boolean)
public ComponentSelector removeAll()This removes all children from all containers in found set.
public ComponentSelector revalidate()Wraps Container#revalidate()
public ComponentSelector forceRevalidate()Wraps Container#forceRevalidate()
public ComponentSelector layoutContainer()Wraps Container#layoutContainer()
public ComponentSelector getComponentAt(int index)This returns a new ComponentSelector which includes a set of all results of calling Container#getComponentAt(int) on containers in this found set.
public boolean containsInSubtree(Component cmp)Returns true if any of the containers in the current found set contains the provided component in its subtree.
public ComponentSelector scrollComponentToVisible(Component cmp)Wraps Container#scrollComponentToVisible(com.codename1.ui.Component)
public ComponentSelector getComponentAt(int x, int y)Returns new ComponentSelector with the set of all components returned from calling int) in the current found set.
public ComponentSelector setScrollableX(boolean b)Wraps Container#setScrollableX(boolean)
public ComponentSelector setScrollableY(boolean b)Wraps Container#setScrollableY(boolean)
public ComponentSelector setScrollIncrement(int b)Wraps Container#setScrollIncrement(int)
public ComponentSelector findFirstFocusable()Creates new ComponentSelector with the set of first focusable elements of each of the containers in the current result set.
public ComponentSelector animateHierarchyAndWait(int duration)Wraps Container#animateHierarchyAndWait(int).
public ComponentSelector animateHierarchy(int duration)Animates the hierarchy of containers in this set.
public ComponentSelector animateHierarchy(int duration, SuccessCallback<ComponentSelector> callback)Wraps Container#animateHierarchy(int).
public ComponentSelector animateHierarchyFadeAndWait(int duration, int startingOpacity)Wraps int).
public ComponentSelector animateHierarchyFade(int duration, int startingOpacity)Wraps Container#animateHierarchyAndWait(int)
public ComponentSelector animateHierarchyFade(int duration, int startingOpacity, SuccessCallback<ComponentSelector> callback)Wraps int).
public ComponentSelector animateLayoutFadeAndWait(int duration, int startingOpacity)Wraps int).
public ComponentSelector animateLayoutFade(int duration, int startingOpacity)Animates layout with fade on all containers in this set.
public ComponentSelector animateLayoutFade(int duration, int startingOpacity, SuccessCallback<ComponentSelector> callback)Wraps int).
public ComponentSelector animateLayout(int duration)Wraps Container#animateLayout(int)
public ComponentSelector animateLayout(int duration, SuccessCallback<ComponentSelector> callback)Wraps Container#animateLayout(int).
public ComponentSelector animateLayoutAndWait(int duration)Wraps Container#animateLayoutAndWait(int)
public ComponentSelector animateUnlayout(int duration, int opacity)Wraps int, java.lang.Runnable)
public ComponentSelector animateUnlayout(int duration, int opacity, SuccessCallback<ComponentSelector> callback)Wraps int, java.lang.Runnable)
public ComponentSelector animateUnlayoutAndWait(int duration, int opacity)Wraps int)
public AnimationManager getAnimationManager()Gets the AnimationManager for the components in this set.
public String getText()Gets the text on the first component in this set that supports this property.
public ComponentSelector setText(String text)Sets the text on all components in found set that support this.
public ComponentSelector setIcon(Image icon)Sets the icon for components in found set.
public ComponentSelector setIcon(char materialIcon, Style style, float size)Sets the icons of all elements in this set to a material icon.
public ComponentSelector setIcon(char materialIcon, float size)Sets the icon of all elements in this set to a material icon.
public ComponentSelector setIcon(char materialIcon)Sets the icon of all elements in this set to a material icon.
public ComponentSelector getComponentForm()Gets the set of all component forms from components in this set.
public ComponentSelector setVerticalAlignment(int valign)Sets vertical alignment of text.
public ComponentSelector setTextPosition(int pos)Sets text position of text.
public ComponentSelector setIconUIID(String uiid)Sets the Icon UIID of elements in found set.
public ComponentSelector setGap(int gap)Sets gap.
public ComponentSelector setShiftText(int shift)Sets shift text.
public ComponentSelector startTicker(long delay, boolean rightToLeft)Wraps boolean)
public ComponentSelector stopTicker()Wraps Label#stopTicker()
public ComponentSelector setTickerEnabled(boolean b)Wraps Label#setTickerEnabled(boolean)
public ComponentSelector setEndsWith3Points(boolean b)Wraps Label#setEndsWith3Points(boolean)
public ComponentSelector setMask(Object mask)Wraps Label#setMask(java.lang.Object)
public ComponentSelector setMaskName(String name)Wraps Label#setMaskName(java.lang.String)
public ComponentSelector setShouldLocalize(boolean b)Wraps Label#setShouldLocalize(boolean)
public ComponentSelector setShiftMillimeters(int b)Wraps Label#setShiftMillimeters(int)
public ComponentSelector setShowEvenIfBlank(boolean b)Wraps Label#setShowEvenIfBlank(boolean)
public ComponentSelector setLegacyRenderer(boolean b)Wraps Label#setLegacyRenderer(boolean)
public ComponentSelector setAutoSizeMode(boolean b)Wraps Label#setAutoSizeMode(boolean)
public ComponentSelector setCommand(Command cmd)Wraps Button#setCommand(com.codename1.ui.Command)
public ComponentSelector setRolloverPressedIcon(Image icon)Wraps Button#setRolloverPressedIcon(com.codename1.ui.Image)
public ComponentSelector setRolloverIcon(Image icon)Wraps Button#setRolloverIcon(com.codename1.ui.Image)
public ComponentSelector setPressedIcon(Image icon)Wraps Button#setPressedIcon(com.codename1.ui.Image)
public ComponentSelector setDisabledIcon(Image icon)Wraps Button#setDisabledIcon(com.codename1.ui.Image)
public ComponentSelector addActionListener(ActionListener l)Adds action listener to applicable components in found set.
public ComponentSelector removeActionListener(ActionListener l)Removes action listeners from components in set.
public ComponentSelector setEditable(boolean b)Wraps TextArea#setEditable(boolean)
public ComponentSelector addDataChangedListener(DataChangedListener l)Wraps TextField#addDataChangedListener(com.codename1.ui.events.DataChangedListener)
public ComponentSelector removeDataChangedListener(DataChangedListener l)Wraps TextField#removeDataChangedListener(com.codename1.ui.events.DataChangedListener)
public ComponentSelector setDoneListener(ActionListener l)Wraps TextField#setDoneListener(com.codename1.ui.events.ActionListener)
public ComponentSelector setPadding(int padding)Sets padding to all sides of found set components in pixels.
public ComponentSelector stripMarginAndPadding()Strips margin and padding from components in found set.
public ComponentSelector setPadding(int top, int right, int bottom, int left)Sets padding to all components in found set.
public ComponentSelector setPaddingMillimeters(float top, float right, float bottom, float left)Sets padding to all components in found set in millimeters.
public ComponentSelector setPaddingMillimeters(float topBottom, float leftRight)Sets padding in millimeters to all components in found set.
public ComponentSelector setPaddingMillimeters(float padding)Sets padding to all components in found set.
public ComponentSelector setPadding(int topBottom, int leftRight)Sets padding on all components in found set.
public ComponentSelector setPaddingPercent(double padding)Sets the padding on all components in found set as a percentage of their respective parents’ dimensions.
public ComponentSelector setPaddingPercent(double topBottom, double leftRight)Sets padding on all components in found set as a percentage of their respective parents’ dimensions.
public ComponentSelector setPaddingPercent(double top, double right, double bottom, double left)Sets padding on all components in found set as a percentage of their respective parents’ dimensions.
public ComponentSelector setMargin(int margin)Sets margin to all sides of found set components in pixels.
public ComponentSelector setMargin(int top, int right, int bottom, int left)Sets margin to all components in found set.
public ComponentSelector setMargin(int topBottom, int leftRight)Sets margin on all components in found set.
public ComponentSelector setMarginPercent(double margin)Sets the margin on all components in found set as a percentage of their respective parents’ dimensions.
public ComponentSelector setMarginPercent(double topBottom, double leftRight)Sets margin on all components in found set as a percentage of their respective parents’ dimensions.
public ComponentSelector setMarginPercent(double top, double right, double bottom, double left)Sets margin on all components in found set as a percentage of their respective parents’ dimensions.
public ComponentSelector setMarginMillimeters(float top, float right, float bottom, float left)Sets margin to all components in found set in millimeters.
public ComponentSelector setMarginMillimeters(float topBottom, float leftRight)Sets margin in millimeters to all components in found set.
public ComponentSelector setMarginMillimeters(float margin)Sets margin to all components in found set.
public Style createProxyStyle()Creates a proxy style to mutate the styles of all component styles in found set.
public ComponentSelector merge(Style style)Merges style with all styles of components in current found set.
public ComponentSelector setBgColor(int bgColor)Wraps Style#setBgColor(int)
public ComponentSelector setAlignment(int alignment)Wraps Style#setAlignment(int)
public ComponentSelector setBgImage(Image bgImage)Wraps Style#setBgImage(com.codename1.ui.Image)
public ComponentSelector setBackgroundType(byte backgroundType)Wraps Style#setBackgroundType(byte)
public ComponentSelector setBackgroundGradientStartColor(int startColor)Wraps Style#setBackgroundGradientStartColor(int)
public ComponentSelector setBackgroundGradientEndColor(int endColor)Wraps (int)
public ComponentSelector setBackgroundGradientRelativeX(float x)Wraps Style#setBackgroundGradientRelativeX(float)
public ComponentSelector setBackgroundGradientRelativeY(float y)Wraps Style#setBackgroundGradientRelativeY(float)
public ComponentSelector setBackgroundGradientRelativeSize(float size)Wraps Style#setBackgroundGradientRelativeSize(float)
public ComponentSelector setFgColor(int color)Wraps Style#setFgColor(int)
public ComponentSelector setFont(Font f)Wraps Style#setFont(com.codename1.ui.Font)
public ComponentSelector setUnderline(boolean b)Wraps Style#setUnderline(boolean)
public ComponentSelector set3DText(boolean t, boolean raised)Wraps boolean)
public ComponentSelector set3DTextNorth(boolean north)Wraps Style#set3DTextNorth(boolean)
public ComponentSelector setOverline(boolean b)Wraps Style#setOverline(boolean)
public ComponentSelector setStrikeThru(boolean b)Wraps Style#setStrikeThru(boolean)
public ComponentSelector setTextDecoration(int textDecoration)Wraps Style#setTextDecoration(int)
public ComponentSelector setBgTransparency(int bgTransparency)Wraps Style#setBgTransparency(byte)
public ComponentSelector setOpacity(int opacity)Wraps Style#setOpacity(int)
public ComponentSelector addStyleListener(StyleListener l)Wraps Style#addStyleListener(com.codename1.ui.events.StyleListener)
public ComponentSelector removeStyleListener(StyleListener l)Wraps Style#removeStyleListener(com.codename1.ui.events.StyleListener)
public ComponentSelector removeStyleListeners()Wraps Style#removeListeners()
public ComponentSelector setBorder(Border b)Wraps Style#setBorder(com.codename1.ui.plaf.Border)
public ComponentSelector setBgPainter(Painter bgPainter)Wraps Style#setBgPainter(com.codename1.ui.Painter)
public ComponentSelector setFontSize(float size)Sets the font size of all components in found set.
public ComponentSelector setMaterialIcon(char icon, float size)Sets the material icon of all labels in the set.
public ComponentSelector setCursor(int cursor)
public ComponentSelector setFontSizeMillimeters(float sizeMM)Sets the font size of all components in found set.
public ComponentSelector setFontSizePercent(double sizePercentage)Sets the fonts size of all components in the found set as a percentage of the font size of the components’ respective parents.
public ComponentSelector first()Returns a set with the first element of the current set, or an empty set if the current set is empty.

Inherited methods

Constructor details

ComponentSelector

public ComponentSelector(Component... cmps)
Creates a component selector that wraps the provided components. The provided components are treated as the “results” of this selector. Not the roots. However you can use #find(java.lang.String) to perform a query using this selector as the roots.

Parameters

cmps Component...
Components to add to this selector results.

ComponentSelector

public ComponentSelector(Set<Component> cmps)
Creates a component selector that wraps the provided components. The provided components are treated as the “results” of this selector. Not the roots. However you can use #find(java.lang.String) to perform a query using this selector as the roots.

Parameters

cmps Set<Component>
Components to add to this selector results.

ComponentSelector

public ComponentSelector(String selector)

Creates a selector that will query the current form. If there is no current form, then this selector will have no roots.

Generally it is better to provide a root explicitly using ComponentSelector.ComponentSelector(java.lang.String, com.codename1.ui.Component...) to ensure that the selector has a tree to walk down.

Parameters

selector String
The selector string.

ComponentSelector

public ComponentSelector(String selector, Component... roots)
Creates a selector with the provided roots. This will only search through the subtrees of the provided roots to find results that match the provided selector string.

Parameters

selector String
The selector string
roots Component...
The roots for this selector.

ComponentSelector

public ComponentSelector(String selector, Collection<Component> roots)
Creates a selector with the provided roots. This will only search through the subtrees of the provided roots to find results that match the provided selector string.

Parameters

selector String
The selector string
roots Collection<Component>
The roots for this selector.

Method details

$

public static ComponentSelector $(Component... cmps)
Deprecated. Use #select(Component...).
Wraps provided components in a ComponentSelector set.

Parameters

cmps Component...
Components to be includd in the set.

Returns

ComponentSelector with specified components.

select

public static ComponentSelector select(Component... cmps)
Alias of #$(com.codename1.ui.Component...)

$

public static ComponentSelector $(ActionEvent e)
Deprecated. Use #select(ActionEvent).
Creates a ComponentInspector with the source component of the provided event.

Parameters

e ActionEvent
The event whose source component is added to the set.

Returns

A ComponentSelector with a single component - the source of the event.

select

public static ComponentSelector select(ActionEvent e)
Alias of #$(com.codename1.ui.events.ActionEvent)

$

public static ComponentSelector $(Runnable r)
Deprecated. Use #select(Runnable).
Wraps Display#callSerially(java.lang.Runnable)

Returns

Empty ComponentSelector.

select

public static ComponentSelector select(Runnable r)
Alias of #$(java.lang.Runnable)

$

public static ComponentSelector $(Set<Component> cmps)
Deprecated. Use #select(Set).
Creates a new ComponentSelector with the provided set of components.

Parameters

cmps Set<Component>
The components to include in the set.

Returns

ComponentSelector with provided components.

select

public static ComponentSelector select(Set<Component> cmps)
Alias of #$(java.util.Set)

$

public static ComponentSelector $(String selector)
Deprecated. Use #select(String).
Creates a new ComponentSelector with the components matched by the provided selector. The current form is used as the root for searches. Will throw a runtime exception if there is no current form.

Parameters

selector String
A selector string that defines which components to include in the set.

Returns

ComponentSelector with matching components.

select

public static ComponentSelector select(String selector)
Alias of #$(java.lang.String)

$

public static ComponentSelector $(String selector, Component... roots)
Deprecated. Use Component...).
Creates a ComponentSelector with the components matched by the provided selector in the provided roots’ subtrees.

Parameters

selector String
Selector string to define which components will be included in the set.
roots Component...
Roots for the selector to search. Only components within the roots’ subtrees will be included in the set.

Returns

ComponentSelector with matching components.

select

public static ComponentSelector select(String selector, Component... roots)
Alias of com.codename1.ui.Component...)

$

public static ComponentSelector $(String selector, Collection<Component> roots)
Deprecated. Use Collection).
Creates a ComponentSelector with the components matched by the provided selector in the provided roots’ subtrees.

Parameters

selector String
Selector string to define which components will be included in the set.
roots Collection<Component>
Roots for the selector to search. Only components within the roots’ subtrees will be included in the set.

Returns

ComponentSelector with matching components.

select

public static ComponentSelector select(String selector, Collection<Component> roots)
Alias of java.util.Collection)

each

public ComponentSelector each(ComponentSelector.ComponentClosure closure)
Applies the given callback to each component in the set.

Parameters

closure ComponentSelector.ComponentClosure
Callback which will be called once for each component in the set.

Returns

Self for chaining.

map

public ComponentSelector map(ComponentSelector.ComponentMapper mapper)
Creates a new set based on the elements of the current set and a mapping function which defines the elements that should be in the new set.

Parameters

mapper ComponentSelector.ComponentMapper
The mapper which will be called once for each element in the set. The return value of the mapper function dictates which component should be included in the resulting set.

Returns

A new set of components.

filter

public ComponentSelector filter(ComponentSelector.Filter filter)
Creates a new set of components formed by filtering the current set using a filter function.

Parameters

filter ComponentSelector.Filter
The filter function called for each element in the set. If it returns true, then the element is included in the resulting set. If false, it will not be included.

Returns

A new set with the results of the filter.

filter

public ComponentSelector filter(String selector)
Filters the current found set against the given selector.

Parameters

selector String
The selector to filter the found set on.

Returns

A new set of elements matching the selector.

parent

public ComponentSelector parent(String selector)
Creates a new set of components consisting of all of the parents of components in this set. Only parent components matching the provided selector will be included in the set.

Parameters

selector String
Selector to filter the parent components.

Returns

New set with parents of elements in current set.

parents

public ComponentSelector parents(String selector)
Creates new set of components consisting of all of the ancestors of components in this set which match the provided selector.

Parameters

selector String
The selector to filter the ancestors.

Returns

New set with ancestors of elements in current set.

closest

public ComponentSelector closest(String selector)
Creates a new set of components consistng of all “closest” ancestors of components in this set which match the provided selector.

Parameters

selector String
The selector to use to match the nearest ancestor.

Returns

New set with ancestors of components in current set.

firstChild

public ComponentSelector firstChild()
Creates new set consisting of the first child of each component in the current set.

Returns

New set with first child of each component in current set.

lastChild

public ComponentSelector lastChild()
Creates new set consisting of the last child of each component in the current set.

Returns

New set with last child of each component in current set.

nextSibling

public ComponentSelector nextSibling()
Creates set of “next” siblings of components in this set.

Returns

New ComponentSelector with next siblings of this set.

prevSibling

public ComponentSelector prevSibling()
Creates set of “previous” siblings of components in this set.

Returns

New ComponentSelector with previous siblings of this set.

animateStyle

public ComponentSelector animateStyle(Style destStyle, int duration, SuccessCallback<ComponentSelector> callback)
Animates this set of components, replacing any modified style properties of the destination style to the components.

Parameters

destStyle Style
The style to apply to the components via animation.
duration int
The duration of the animation (ms)
callback SuccessCallback<ComponentSelector>
Callback to call after animation is complete.

Returns

Self for chaining

fadeIn

public ComponentSelector fadeIn()
Fade in this set of components. Prior to calling this, the component visibility should be set to “false”. This uses the default duration of 500ms.

Returns

Self for chaining.

fadeIn

public ComponentSelector fadeIn(int duration)
Fade in this set of components. Prior to calling this, the component visibility should be set to “false”.

Parameters

duration int
The duration of the fade in.

Returns

Self for chaining.

fadeIn

public ComponentSelector fadeIn(int duration, SuccessCallback<ComponentSelector> callback)
Fade in this set of components. Prior to calling this, the component visibility should be set to “false”.

Parameters

duration int
The duration of the fade in.
callback SuccessCallback<ComponentSelector>
Callback to run when animation completes.

fadeInAndWait

public ComponentSelector fadeInAndWait()
Fades in this component and blocks until animation is complete.

Returns

Self for chaining.

fadeInAndWait

public ComponentSelector fadeInAndWait(int duration)
Fades in this component and blocks until animation is complete.

Parameters

duration int
The duration of the animation.

Returns

Self for chaining.

isVisible

public boolean isVisible()
Returns true if the first component in this set is visible.

Returns

True if first component in this set is visible.

setVisible

public ComponentSelector setVisible(boolean visible)
Wrapper for Component#setVisible(boolean)

Parameters

visible boolean
True to make all components in result set visible. False for hidden.

Returns

Self for chaining.

isHidden

public boolean isHidden()
Returns true if first component in this set is hidden.

Returns

True if first component in set is hidden.

setHidden

public ComponentSelector setHidden(boolean b)
Wraps Component#setHidden(boolean)

fadeOut

public ComponentSelector fadeOut()
Fades out components in this set. Uses default duration of 500ms.

Returns

Self for chaining.

fadeOut

public ComponentSelector fadeOut(int duration)
Fades out components in this set.

Parameters

duration int
Duration of animation.

Returns

Self for chaining.

fadeOut

public ComponentSelector fadeOut(int duration, SuccessCallback<ComponentSelector> callback)
Fades out components in this set.

Parameters

duration int
Duration of animation.
callback SuccessCallback<ComponentSelector>
Callback to run when animation completes.

Returns

Self for chaining.

slideUp

public ComponentSelector slideUp(int duration)
Hide the matched components with a sliding motion.

Parameters

duration int
Duration of animation

Returns

Self for chaining.

slideUp

public ComponentSelector slideUp(int duration, SuccessCallback<ComponentSelector> callback)
Hide the matched elements with a sliding motion.

Parameters

duration int
Duration of animation.
callback SuccessCallback<ComponentSelector>
Callback to run when animation completes

Returns

Self for chaining.

slideUpAndWait

public ComponentSelector slideUpAndWait(int duration)
Hide the matched elements with a sliding motion. Blocks until animation is complete.

Parameters

duration int
Duration of animation.

Returns

Self for chaining.

slideDown

public ComponentSelector slideDown()
Display the matched elements with a sliding motion. Uses default duration of 500ms

Returns

Self for chaining.

slideUp

public ComponentSelector slideUp()
Hide the matched elements with a sliding motion. Uses default duration of 500ms

Returns

Self for chaining.

slideDown

public ComponentSelector slideDown(int duration)
Display the matched elements with a sliding motion.

Parameters

duration int
Duration of animation.

Returns

Self for chaining.

slideDown

public ComponentSelector slideDown(int duration, SuccessCallback<ComponentSelector> callback)
Display the matched elements with a sliding motion.

Parameters

duration int
Duration of animation.
callback SuccessCallback<ComponentSelector>
Callback to run when animation completes.

Returns

Self for chaining.

slideDownAndWait

public ComponentSelector slideDownAndWait(int duration)
Display the matched elements with a sliding motion. Blocks until animation is complete.

Parameters

duration int
Duration of animation.

Returns

Self for chaining.

fadeOutAndWait

public ComponentSelector fadeOutAndWait(int duration)
Hide the matched elements by fading them to transparent. Blocks thread until animation is complete.

Parameters

duration int
Duration of animation.

Returns

Self for chaining.

replace

public ComponentSelector replace(ComponentSelector.ComponentMapper mapper)
Replaces the matched components within respective parents with replacements defined by the provided mapper. Replacements are replaced in the UI itself (i.e. c.getParent().replace(c, replacement)) with an empty transition.

Parameters

mapper ComponentSelector.ComponentMapper
Mapper that defines the replacements for each component in the set. If the mapper returns the input component, then no change is made for that component. A null return value cause the component to be removed from its parent. Returning a Component results in that component replacing the original component within its parent.

Returns

A new ComponentSelector with the replacement components.

replace

public ComponentSelector replace(ComponentSelector.ComponentMapper mapper, Transition t)
Replaces the matched components within respective parents with replacements defined by the provided mapper. Replacements are replaced in the UI itself (i.e. c.getParent().replace(c, replacement)) with the provided transition.

Parameters

mapper ComponentSelector.ComponentMapper
Mapper that defines the replacements for each component in the set. If the mapper returns the input component, then no change is made for that component. A null return value cause the component to be removed from its parent. Returning a Component results in that component replacing the original component within its parent.
t Transition
Transition to use for replacements.

Returns

A new ComponentSelector with the replacement components.

replaceAndWait

public ComponentSelector replaceAndWait(ComponentSelector.ComponentMapper mapper, Transition t)
Replaces the matched components within respective parents with replacements defined by the provided mapper. Replacements are replaced in the UI itself (i.e. c.getParent().replace(c, replacement)) with the provided transition. Blocks the thread until the transition animation is complete.

Parameters

mapper ComponentSelector.ComponentMapper
Mapper that defines the replacements for each component in the set. If the mapper returns the input component, then no change is made for that component. A null return value cause the component to be removed from its parent. Returning a Component results in that component replacing the original component within its parent.
t Transition
Not documented.

Returns

A new ComponentSelector with the replacement components.

find

public ComponentSelector find(String selector)
Uses the results of this selector as the roots to create a new selector with the provided selector string.

Parameters

selector String
The selector string.

Returns

A new ComponentSelector with the results of the query.

iterator

public Iterator<Component> iterator()
Returns the results of this selector.

Returns

An Iterator instance.

getStyle

public Style getStyle()
Gets a proxy style that wraps the result of Component#getStyle() of each component in set.

getStyle

public Style getStyle(Component component)

Gets a style object for the given component that can be used to modify the component’s styles. This takes into account any state-pseudo classes that were used to create this selector so that the style returned will be appropriate.

E.g.

`ComponentSelector sel = new ComponentSelector("Button:pressed");
Style style = sel.getStyle(sel.get(0));
    // This should be equivalent to sel.get(0).getPressedStyle()

sel = new ComponentSelector("Button");
style = sel.getStyle(sel.get(0));
    // This should be equivalent to sel.get(0).getAllStyles()

sel = new ComponentSelector("Button:pressed, Button:selected");
style = sel.getStyle(sel.get(0));
    // This should be same as
    // Style.createProxyStyle(sel.get(0).getPressedStyle(), sel.get(0).getSelectedStyle())`

Parameters

component Component
The component whose style object we wish to obtain.

Returns

A style object that will allow us to modify the style of the given component.

getSelectedStyle

public Style getSelectedStyle()
Returns a proxy style for all of the selected styles of the components in this set.

Returns

Proxy style to easily change properties of the selected styles of all components in this set.

setSelectedStyle

public ComponentSelector setSelectedStyle(Style style)
Sets selected style of all components in found set. Wraps Component#setSelectedStyle(com.codename1.ui.plaf.Style)

selectSelectedStyle

public ComponentSelector selectSelectedStyle()
Sets the current style to the selected style. Style mutation methods called after calling this method will modify the components’ “selected style”.

Returns

Self for chaining.

selectUnselectedStyle

public ComponentSelector selectUnselectedStyle()
Sets the current style to the unselected style. Style mutation methods called after calling this method will modify the components’ “unselected style”.

Returns

Self for chaining.

selectPressedStyle

public ComponentSelector selectPressedStyle()
Sets the current style to the pressed style. Style mutation methods called after calling this method will modify the components’ “pressed style”.

Returns

Self for chaining.

selectDisabledStyle

public ComponentSelector selectDisabledStyle()
Sets the current style to the disabled style. Style mutation methods called after calling this method will modify the components’ “disabled style”.

Returns

Self for chaining.

selectAllStyles

public ComponentSelector selectAllStyles()
Sets the current style to each component’s ALL STYLES proxy style. Style mutation methods called after calling this method will modify the components’ “all styles” proxy style.

Returns

Self for chaining.

getUnselectedStyle

public Style getUnselectedStyle()
Returns a proxy style for all of the unselected styles of the components in this set.

Returns

Proxy style to easily change properties of the unselected styles of all components in this set.

setUnselectedStyle

public ComponentSelector setUnselectedStyle(Style style)
Sets unselected style of all components in found set. Wraps Component#setUnselectedStyle(com.codename1.ui.plaf.Style)

getPressedStyle

public Style getPressedStyle()
Returns a proxy style for all of the pressed styles of the components in this set.

Returns

Proxy style to easily change properties of the pressed styles of all components in this set.

setPressedStyle

public ComponentSelector setPressedStyle(Style style)
Sets pressed style of all components in found set. Wraps Component#setPressedStyle(com.codename1.ui.plaf.Style)

getDisabledStyle

public Style getDisabledStyle()
Returns a proxy style for all of the disabled styles of the components in this set.

Returns

Proxy style to easily change properties of the disabled styles of all components in this set.

setDisabledStyle

public ComponentSelector setDisabledStyle(Style style)
Sets disabled style of all components in found set. Wraps Component#setDisabledStyle(com.codename1.ui.plaf.Style)

getAllStyles

public Style getAllStyles()
Returns a proxy style for all of the “all” styles of the components in this set.

Returns

Proxy style to easily change properties of the “all” styles of all components in this set.

size

public int size()
Returns number of results found.

Returns

the number of elements in this set.

isEmpty

public boolean isEmpty()
Returns true if this set has no elements.

Returns

True if there were no results.

contains

public boolean contains(Object o)
Checks if an object is contained in result set.

Returns

true if object is an element of this set, false otherwise.

toArray

public Object[] toArray()
Returns results as an array.

Returns

an array of the elements from this set.

toArray

public <T> T[] toArray(T[] a)
Returns results as an array.

Parameters

a T[]
the array.

Returns

an array of the elements from this set.

Throws

ArrayStoreException
when the type of an element in this set cannot be stored in the type of the specified array.

add

public boolean add(Component e)
Explicitly adds a component to the result set.

Returns

True on success

append

public ComponentSelector append(Component child)
Appends a child component to the first container in this set. Same as calling Container#add(com.codename1.ui.Component) padding child on first container in this set.

Parameters

child Component
Component to add to container.

Returns

Self for chaining.

append

public ComponentSelector append(Object constraint, Component child)
Appends a child component to the first container in this set. Same as calling com.codename1.ui.Component) padding child on first container in this set.

append

public ComponentSelector append(ComponentSelector.ComponentMapper mapper)
Append a child element to each container in this set. The mapper callback will receive a Container as input (that is the parent to be added to), and should return a Component that is to be added to it. If the mapper returns null, then nothing is added to that container.

append

public ComponentSelector append(Object constraint, ComponentSelector.ComponentMapper mapper)
Append a child element to each container in this set. The mapper callback will receive a Container as input (that is the parent to be added to), and should return a Component that is to be added to it. If the mapper returns null, then nothing is added to that container.

add

public ComponentSelector add(Component e, boolean chain)
Fluent API wrapper for #add(com.codename1.ui.Component)

Parameters

e Component
Component to add to set.
chain boolean
Dummy argument so that this version would have a different signature than Set#add(java.lang.Object)

Returns

Self for chaining.

remove

public boolean remove(Object o)
Explicitly removes a component from the result set.

Returns

Self for chaining.

remove

public ComponentSelector remove(Object o, boolean chain)
Fluent API wrapper for #remove(java.lang.Object).

Parameters

o Object
The component to remove from set.
chain boolean
Dummy argument so that this version would have a different signature than Set#remove(java.lang.Object)

Returns

Self for chaining.

containsAll

public boolean containsAll(Collection<?> c)
Checks if the result set contains all of the components found in the provided collection.

Returns

true if all objects in the specified collection are elements of this set, false otherwise.

addAll

public boolean addAll(Collection<? extends Component> c)
Adds all components in the given collection to the result set.

Returns

true if this set is modified, false otherwise.

Throws

UnsupportedOperationException
when adding to this set is not supported.
ClassCastException
when the class of an object is inappropriate for this set.
IllegalArgumentException
when an object cannot be added to this set.

addAll

public ComponentSelector addAll(Collection<? extends Component> c, boolean chain)
Fluent API wrapper for #addAll(java.util.Collection).

Parameters

c Collection<? extends Component>
The set of components to add to this set.
chain boolean
Dummy argument so that this version would have a different signature than #addAll(java.util.Collection)

Returns

Self for chaining.

asComponent

public Component asComponent()
Returns the first component in this set. This is useful for single component sets (e.g. $(new Label()).setFgColor(0xff0000).asComponent()).

Returns

The first component in this set.

asComponent

public <T extends Component> T asComponent(Class<T> type)
Returns the first component in this set. This is useful for single component sets (e.g. $(new Label()).setFgColor(0xff0000).asComponent(Label.class)).

Parameters

type Class<T>
The type of component that is expected to be returned.

Returns

The first component in this set.

asList

public List<Component> asList()
Returns the components of this set as a List. Note that order of elements is not maintained since ComponentSelector is a set (i.e. has no notion of element order).

Returns

The components in this set as a list.

retainAll

public boolean retainAll(Collection<?> c)
Retains only elements of the result set that are contained in the provided collection.

Returns

true if this set was modified, false otherwise.

Throws

UnsupportedOperationException
when removing from this set is not supported.

retainAll

public ComponentSelector retainAll(Collection<?> c, boolean chain)
Fluent API wrapper for #retainAll(java.util.Collection)

Parameters

c Collection<?>
The collection to retain.
chain boolean
Dummy arg.

Returns

Self for chaining.

removeAll

public boolean removeAll(Collection<?> c)
Removes all of the components in the provided collection from the result set.

Returns

true if this set was modified, false otherwise.

Throws

UnsupportedOperationException
when removing from this set is not supported.

removeAll

public ComponentSelector removeAll(Collection<?> c, boolean chain)
Fluent API wrapper for #removeAll(java.util.Collection)

Parameters

c Collection<?>
Collection with components to remove,
chain boolean
Dummy arg.

Returns

Self for chaining.

clear

public void clear()
Clears the result set.

Throws

UnsupportedOperationException
when removing from this set is not supported.

clear

public ComponentSelector clear(boolean chain)
Fluent API wrapper for (@link #clear()}

Parameters

chain boolean
Dummy arg

Returns

Self for chaining.

toString

public String toString()
Returns a string representation of the object. In general, the toString method returns a string that “textually represents” this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method. The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character `@’, and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of: getClass().getName() + ‘@’ + Integer.toHexString(hashCode())

addTags

public ComponentSelector addTags(String... tags)
Adds the given tags to all elements in the result set.

Parameters

tags String...
Tags to add.

Returns

Self for chaining.

removeTags

public ComponentSelector removeTags(String... tags)
Removes the given tags from all elements in the result set.

getParent

public ComponentSelector getParent()
Gets the set of all “parent” components of components in the result set.

Returns

New Component selector with respective parents of the components in the current result set.

setSameWidth

public ComponentSelector setSameWidth()
Wrapper for Component#setSameWidth(com.codename1.ui.Component...). Passes all components in the result set as parameters of this method, effectively making them all the same width.

setSameHeight

public ComponentSelector setSameHeight()
Wrapper for Component#setSameHeight(com.codename1.ui.Component...). Passes all components in the result set as parameters of this method, effectively making them all the same height.

clearClientProperties

public ComponentSelector clearClientProperties()
Wrapper for Component#clearClientProperties().

Returns

Self for Chaining.

putClientProperty

public ComponentSelector putClientProperty(String key, Object value)
Wrapper for java.lang.Object)

Parameters

key String
Property key
value Object
Property value

Returns

Self for chaining.

getClientProperty

public Object getClientProperty(String key)
Gets a client property from the first component in the set. Wraps Component#getClientProperty(java.lang.String)

Parameters

key String
The key of the client property to retrieve.

Returns

The value of the client property.

setDirtyRegion

public ComponentSelector setDirtyRegion(Rectangle rect)
Wrapper for Component#setDirtyRegion(com.codename1.ui.geom.Rectangle)

Parameters

rect Rectangle
Dirty region

Returns

Self for chaining.

setX

public ComponentSelector setX(int x)
Wrapper for Component#setX(int)

setY

public ComponentSelector setY(int y)
Wrapper for Component#setY(int)

setWidth

public ComponentSelector setWidth(int width)
Wrapper for Component#setWidth(int)

setHeight

public ComponentSelector setHeight(int height)
Wrapper for Component#setHeight(int)

setPreferredSize

public ComponentSelector setPreferredSize(Dimension dim)
Wrapper for Component#setPreferredSize(com.codename1.ui.geom.Dimension)

setPreferredH

public ComponentSelector setPreferredH(int h)
Wrapper for Component#setPreferredH(int)

setPreferredW

public ComponentSelector setPreferredW(int w)
Wrapper for Component#setPreferredW(int)

setScrollSize

public ComponentSelector setScrollSize(Dimension size)
Wrapper for Component#setScrollSize

setSize

public ComponentSelector setSize(Dimension size)
Wrapper for Component#setSize(com.codename1.ui.geom.Dimension)

setUIID

public ComponentSelector setUIID(String uiid)
Wrapper for Component#setUIID(java.lang.String)

remove

public ComponentSelector remove()
Wrapper for Component#remove(). This will remove all of the components in the current found set from their respective parents.

addFocusListener

public ComponentSelector addFocusListener(FocusListener l)
Adds a focus listener to all components in found set. Wraps Component#addFocusListener(com.codename1.ui.events.FocusListener)

removeFocusListener

public ComponentSelector removeFocusListener(FocusListener l)
Removes focus listener from all components in found set. Wraps Component#removeFocusListener(com.codename1.ui.events.FocusListener)

addScrollListener

public ComponentSelector addScrollListener(ScrollListener l)
Adds scroll listener to all components in found set. Wraps Component#addScrollListener(com.codename1.ui.events.ScrollListener)

removeScrollListener

public ComponentSelector removeScrollListener(ScrollListener l)
Removes scroll listener from all components in found set. Wraps Component#removeScrollListener(com.codename1.ui.events.ScrollListener)

setSelectCommandText

public ComponentSelector setSelectCommandText(String text)
Sets select command text on all components in found set. Wraps Component#setSelectCommandText(java.lang.String)

setLabelForComponent

public ComponentSelector setLabelForComponent(Label l)
Wraps Component#setLabelForComponent(com.codename1.ui.Label)

paintBackgrounds

public ComponentSelector paintBackgrounds(Graphics g)
Wraps Component#paintBackgrounds(com.codename1.ui.Graphics)

paintComponent

public ComponentSelector paintComponent(Graphics g)
Wraps Component#paintComponent(com.codename1.ui.Graphics)

paint

public ComponentSelector paint(Graphics g)
Wraps Component#paint(com.codename1.ui.Graphics)

contains

public boolean contains(int x, int y)
Returns true if any of the components in the found set contains the provided coordinate. Wraps int)

setFocusable

public ComponentSelector setFocusable(boolean focus)
Sets all components in the found set focusability. Wraps Component#setFocusable(boolean)

repaint

public ComponentSelector repaint()
Wraps Component#repaint()

repaint

public ComponentSelector repaint(int x, int y, int w, int h)
Wraps int, int, int)

setScrollAnimationSpeed

public ComponentSelector setScrollAnimationSpeed(int speed)
Wraps Component#setScrollAnimationSpeed(int)

setSmoothScrolling

public ComponentSelector setSmoothScrolling(boolean smooth)
Wraps Component#setSmoothScrolling(boolean)

addDropListener

public ComponentSelector addDropListener(ActionListener l)
Adds a drop listener to all components in found set. Wraps Component#addDropListener(com.codename1.ui.events.ActionListener)

removeDropListener

public ComponentSelector removeDropListener(ActionListener l)
Removes a drop listener from all components in found set. Wraps Component#removeDropListener(com.codename1.ui.events.ActionListener)

addDragOverListener

public ComponentSelector addDragOverListener(ActionListener l)
Adds drag over listener to all components in found set. Wraps Component#addDragOverListener(com.codename1.ui.events.ActionListener)

removeDragOverListener

public ComponentSelector removeDragOverListener(ActionListener l)
Removes drag over listener from all components in found set. Wraps Component#removeDragOverListener(com.codename1.ui.events.ActionListener)

addPointerPressedListener

public ComponentSelector addPointerPressedListener(ActionListener l)
Adds pointer pressed listener to all components in found set. Wraps Component#addPointerPressedListener(com.codename1.ui.events.ActionListener)

addLongPressListener

public ComponentSelector addLongPressListener(ActionListener l)
Adds long pointer pressed listener to all components in found set. Wraps Component#addLongPressListener(com.codename1.ui.events.ActionListener)

removePointerPressedListener

public ComponentSelector removePointerPressedListener(ActionListener l)
Removes pointer pressed listener from all components in found set. Wraps Component#removePointerPressedListener(com.codename1.ui.events.ActionListener)

removeLongPressListener

public ComponentSelector removeLongPressListener(ActionListener l)
Removes long pointer pressed listener from all components in found set. Wraps Component#removeLongPressListener(com.codename1.ui.events.ActionListener)

addPointerReleasedListener

public ComponentSelector addPointerReleasedListener(ActionListener l)
Adds pointer released listener to all components in found set. Wraps Component#addPointerReleasedListener(com.codename1.ui.events.ActionListener)

removePointerReleasedListener

public ComponentSelector removePointerReleasedListener(ActionListener l)
Removes pointer released listener from all components in found set. Wraps Component#removePointerReleasedListener(com.codename1.ui.events.ActionListener)

addPointerDraggedListener

public ComponentSelector addPointerDraggedListener(ActionListener l)
Adds pointer dragged listener to all components in found set. Wraps Component#addPointerDraggedListener(com.codename1.ui.events.ActionListener)

removePointerDraggedListener

public ComponentSelector removePointerDraggedListener(ActionListener l)
REmoves pointer dragged listener from all components in found set. Wraps Component#removePointerDraggedListener(com.codename1.ui.events.ActionListener)

requestFocus

public ComponentSelector requestFocus()
Wraps Component#requestFocus()

refreshTheme

public ComponentSelector refreshTheme()
Wraps Component#refreshTheme()

refreshTheme

public ComponentSelector refreshTheme(boolean merge)
Wraps Component#refreshTheme(boolean)

setCellRenderer

public ComponentSelector setCellRenderer(boolean cell)
Wraps Component#setCellRenderer(boolean)

setScrollVisible

public ComponentSelector setScrollVisible(boolean vis)
Wraps Component#setScrollVisible(boolean)

setEnabled

public ComponentSelector setEnabled(boolean enabled)
Wraps Component#setEnabled(boolean)

setName

public ComponentSelector setName(String name)
Wraps Component#setName(java.lang.String)

setRTL

public ComponentSelector setRTL(boolean rtl)
Wraps Component#setRTL(boolean)

setTactileTouch

public ComponentSelector setTactileTouch(boolean t)
Wraps Component#setTactileTouch(boolean)

setPropertyValue

public ComponentSelector setPropertyValue(String key, Object value)
Wraps java.lang.Object)

paintLockRelease

public ComponentSelector paintLockRelease()
Wraps Component#paintLockRelease()

setSnapToGrid

public ComponentSelector setSnapToGrid(boolean s)
Wraps Component#setSnapToGrid(boolean)

isIgnorePointerEvents

public boolean isIgnorePointerEvents()

setIgnorePointerEvents

public ComponentSelector setIgnorePointerEvents(boolean ignore)

setFlatten

public ComponentSelector setFlatten(boolean f)
Wraps Component#setFlatten(boolean)

setTensileLength

public ComponentSelector setTensileLength(int len)
Wraps Component#setTensileLength(int)

setGrabsPointerEvents

public ComponentSelector setGrabsPointerEvents(boolean g)
Wraps Component#setGrabsPointerEvents(boolean)

setScrollOpacityChangeSpeed

public ComponentSelector setScrollOpacityChangeSpeed(int scrollOpacityChangeSpeed)
Wraps Component#setScrollOpacityChangeSpeed(int)

growShrink

public ComponentSelector growShrink(int duration)
Wraps Component#growShrink(int)

setDraggable

public ComponentSelector setDraggable(boolean draggable)
Wraps Component#setDraggable(boolean)

setDropTarget

public ComponentSelector setDropTarget(boolean target)
Wraps Component#setDropTarget(boolean)

setHideInPortait

public ComponentSelector setHideInPortait(boolean hide)
Wraps Component#setHideInPortrait(boolean)

setHidden

public ComponentSelector setHidden(boolean b, boolean changeMargin)
Wraps boolean)

setComponentState

public ComponentSelector setComponentState(Object state)
Wraps Component#setComponentState(java.lang.Object)

setLeadComponent

public ComponentSelector setLeadComponent(Component lead)
Wraps Container#setLeadComponent(com.codename1.ui.Component)

setLayout

public ComponentSelector setLayout(Layout layout)
Wraps Container#setLayout(com.codename1.ui.layouts.Layout)

invalidate

public ComponentSelector invalidate()
Wraps Container#invalidate()

setShouldCalcPreferredSize

public ComponentSelector setShouldCalcPreferredSize(boolean shouldCalcPreferredSize)
Wraps Container#setShouldCalcPreferredSize(boolean)

applyRTL

public ComponentSelector applyRTL(boolean rtl)
Wraps Container#applyRTL(boolean)

removeAll

public ComponentSelector removeAll()
This removes all children from all containers in found set. Not to be confused with #clear(), which removes components from the found set, but not from their respective parents. Wraps Container#removeAll()

revalidate

public ComponentSelector revalidate()
Wraps Container#revalidate()

forceRevalidate

public ComponentSelector forceRevalidate()
Wraps Container#forceRevalidate()

layoutContainer

public ComponentSelector layoutContainer()
Wraps Container#layoutContainer()

getComponentAt

public ComponentSelector getComponentAt(int index)
This returns a new ComponentSelector which includes a set of all results of calling Container#getComponentAt(int) on containers in this found set. This effectively allows us to get all of the ith elements of all matched components.

Returns

New ComponentSelector with indexth child of each container in the current found set.

containsInSubtree

public boolean containsInSubtree(Component cmp)
Returns true if any of the containers in the current found set contains the provided component in its subtree. Wraps Container#contains(com.codename1.ui.Component)

scrollComponentToVisible

public ComponentSelector scrollComponentToVisible(Component cmp)
Wraps Container#scrollComponentToVisible(com.codename1.ui.Component)

getComponentAt

public ComponentSelector getComponentAt(int x, int y)
Returns new ComponentSelector with the set of all components returned from calling int) in the current found set.

Returns

New ComponentSelector with components at the given coordinates.

setScrollableX

public ComponentSelector setScrollableX(boolean b)
Wraps Container#setScrollableX(boolean)

setScrollableY

public ComponentSelector setScrollableY(boolean b)
Wraps Container#setScrollableY(boolean)

setScrollIncrement

public ComponentSelector setScrollIncrement(int b)
Wraps Container#setScrollIncrement(int)

findFirstFocusable

public ComponentSelector findFirstFocusable()
Creates new ComponentSelector with the set of first focusable elements of each of the containers in the current result set.

Returns

New component selector with first focusable element of each container in current found set.

animateHierarchyAndWait

public ComponentSelector animateHierarchyAndWait(int duration)
Wraps Container#animateHierarchyAndWait(int).

animateHierarchy

public ComponentSelector animateHierarchy(int duration)
Animates the hierarchy of containers in this set. Wraps Container#animateHierarchy(int)

animateHierarchy

public ComponentSelector animateHierarchy(int duration, SuccessCallback<ComponentSelector> callback)
Wraps Container#animateHierarchy(int).

animateHierarchyFadeAndWait

public ComponentSelector animateHierarchyFadeAndWait(int duration, int startingOpacity)
Wraps int).

animateHierarchyFade

public ComponentSelector animateHierarchyFade(int duration, int startingOpacity)
Wraps Container#animateHierarchyAndWait(int)

Parameters

duration int
The duration of the animation.
startingOpacity int
The starting opacity.

Returns

Self for chaining.

animateHierarchyFade

public ComponentSelector animateHierarchyFade(int duration, int startingOpacity, SuccessCallback<ComponentSelector> callback)
Wraps int).

animateLayoutFadeAndWait

public ComponentSelector animateLayoutFadeAndWait(int duration, int startingOpacity)
Wraps int).

animateLayoutFade

public ComponentSelector animateLayoutFade(int duration, int startingOpacity)
Animates layout with fade on all containers in this set. Wraps int).

Returns

Self for chaining.

animateLayoutFade

public ComponentSelector animateLayoutFade(int duration, int startingOpacity, SuccessCallback<ComponentSelector> callback)
Wraps int).

animateLayout

public ComponentSelector animateLayout(int duration)
Wraps Container#animateLayout(int)

animateLayout

public ComponentSelector animateLayout(int duration, SuccessCallback<ComponentSelector> callback)
Wraps Container#animateLayout(int).

animateLayoutAndWait

public ComponentSelector animateLayoutAndWait(int duration)
Wraps Container#animateLayoutAndWait(int)

animateUnlayout

public ComponentSelector animateUnlayout(int duration, int opacity)
Wraps int, java.lang.Runnable)

animateUnlayout

public ComponentSelector animateUnlayout(int duration, int opacity, SuccessCallback<ComponentSelector> callback)
Wraps int, java.lang.Runnable)

Parameters

duration int
Not documented.
opacity int
Not documented.
callback SuccessCallback<ComponentSelector>
Callback to run when animation has completed.

animateUnlayoutAndWait

public ComponentSelector animateUnlayoutAndWait(int duration, int opacity)
Wraps int)

getAnimationManager

public AnimationManager getAnimationManager()
Gets the AnimationManager for the components in this set.

Returns

The AnimationManager for the components in this set.

getText

public String getText()
Gets the text on the first component in this set that supports this property. Currently this works with Label, TextArea, SpanLabel, and SpanButtons, and subclasses thereof.

setText

public ComponentSelector setText(String text)
Sets the text on all components in found set that support this. Currently this works with Label, TextArea, SpanLabel, and SpanButtons, and subclasses thereof.

Parameters

text String
The text to set in the componnet.

setIcon

public ComponentSelector setIcon(Image icon)
Sets the icon for components in found set. Only relevant to Labels, SpanLabels, and SpanButtons, and subclasses thereof.

setIcon

public ComponentSelector setIcon(char materialIcon, Style style, float size)
Sets the icons of all elements in this set to a material icon.

Parameters

materialIcon char
Material icon charcode.
style Style
The style for the icon.
size float
The size for the icon. (in mm)

Returns

Self for chaining.

setIcon

public ComponentSelector setIcon(char materialIcon, float size)
Sets the icon of all elements in this set to a material icon. This will use the foreground color of each label as the icon’s foreground color.

Parameters

materialIcon char
The icon charcode.
size float
The size of the icon (in mm)

Returns

Self for chaining

setIcon

public ComponentSelector setIcon(char materialIcon)
Sets the icon of all elements in this set to a material icon. This will use the foreground color of the label.

Parameters

materialIcon char
The material icon charcode.

Returns

Self for chaining.

getComponentForm

public ComponentSelector getComponentForm()
Gets the set of all component forms from components in this set.

Returns

New ComponentSelector with forms all components in this set.

setVerticalAlignment

public ComponentSelector setVerticalAlignment(int valign)
Sets vertical alignment of text.

setTextPosition

public ComponentSelector setTextPosition(int pos)
Sets text position of text. Only relevant to labels.

setIconUIID

public ComponentSelector setIconUIID(String uiid)
Sets the Icon UIID of elements in found set.

Parameters

uiid String
The UIID for icons.

Returns

Self for chaining.

setGap

public ComponentSelector setGap(int gap)
Sets gap. Only relevant to labels.

setShiftText

public ComponentSelector setShiftText(int shift)
Sets shift text. Only relevant to labels.

startTicker

public ComponentSelector startTicker(long delay, boolean rightToLeft)
Wraps boolean)

stopTicker

public ComponentSelector stopTicker()
Wraps Label#stopTicker()

setTickerEnabled

public ComponentSelector setTickerEnabled(boolean b)
Wraps Label#setTickerEnabled(boolean)

setEndsWith3Points

public ComponentSelector setEndsWith3Points(boolean b)
Wraps Label#setEndsWith3Points(boolean)

setMask

public ComponentSelector setMask(Object mask)
Wraps Label#setMask(java.lang.Object)

setMaskName

public ComponentSelector setMaskName(String name)
Wraps Label#setMaskName(java.lang.String)

setShouldLocalize

public ComponentSelector setShouldLocalize(boolean b)
Wraps Label#setShouldLocalize(boolean)

setShiftMillimeters

public ComponentSelector setShiftMillimeters(int b)
Wraps Label#setShiftMillimeters(int)

setShowEvenIfBlank

public ComponentSelector setShowEvenIfBlank(boolean b)
Wraps Label#setShowEvenIfBlank(boolean)

setLegacyRenderer

public ComponentSelector setLegacyRenderer(boolean b)
Wraps Label#setLegacyRenderer(boolean)

setAutoSizeMode

public ComponentSelector setAutoSizeMode(boolean b)
Wraps Label#setAutoSizeMode(boolean)

setCommand

public ComponentSelector setCommand(Command cmd)
Wraps Button#setCommand(com.codename1.ui.Command)

setRolloverPressedIcon

public ComponentSelector setRolloverPressedIcon(Image icon)
Wraps Button#setRolloverPressedIcon(com.codename1.ui.Image)

setRolloverIcon

public ComponentSelector setRolloverIcon(Image icon)
Wraps Button#setRolloverIcon(com.codename1.ui.Image)

setPressedIcon

public ComponentSelector setPressedIcon(Image icon)
Wraps Button#setPressedIcon(com.codename1.ui.Image)

setDisabledIcon

public ComponentSelector setDisabledIcon(Image icon)
Wraps Button#setDisabledIcon(com.codename1.ui.Image)

addActionListener

public ComponentSelector addActionListener(ActionListener l)
Adds action listener to applicable components in found set. Currently this will apply to Buttons, Lists, Sliders, TextAreas, OnOffSwitches, SpanButtons, and subclasses thereof.

removeActionListener

public ComponentSelector removeActionListener(ActionListener l)
Removes action listeners from components in set.

Parameters

l ActionListener
The listener to remove

setEditable

public ComponentSelector setEditable(boolean b)
Wraps TextArea#setEditable(boolean)

addDataChangedListener

public ComponentSelector addDataChangedListener(DataChangedListener l)
Wraps TextField#addDataChangedListener(com.codename1.ui.events.DataChangedListener)

removeDataChangedListener

public ComponentSelector removeDataChangedListener(DataChangedListener l)
Wraps TextField#removeDataChangedListener(com.codename1.ui.events.DataChangedListener)

setDoneListener

public ComponentSelector setDoneListener(ActionListener l)
Wraps TextField#setDoneListener(com.codename1.ui.events.ActionListener)

setPadding

public ComponentSelector setPadding(int padding)
Sets padding to all sides of found set components in pixels.

Parameters

padding int
Padding in pixels

stripMarginAndPadding

public ComponentSelector stripMarginAndPadding()
Strips margin and padding from components in found set.

Returns

Self for chaining.

setPadding

public ComponentSelector setPadding(int top, int right, int bottom, int left)
Sets padding to all components in found set.

Parameters

top int
Top padding in pixels.
right int
Right padding in pixels
bottom int
Bottom padding in pixels.
left int
Left padding in pixels.

setPaddingMillimeters

public ComponentSelector setPaddingMillimeters(float top, float right, float bottom, float left)
Sets padding to all components in found set in millimeters.

Parameters

top float
Top padding in mm.
right float
Right padding in mm
bottom float
Bottom padding in mm.
left float
Left padding in mm.

setPaddingMillimeters

public ComponentSelector setPaddingMillimeters(float topBottom, float leftRight)
Sets padding in millimeters to all components in found set.

Parameters

topBottom float
Top and bottom padding in mm.
leftRight float
Left and right padding in mm.

setPaddingMillimeters

public ComponentSelector setPaddingMillimeters(float padding)
Sets padding to all components in found set.

Parameters

padding float
Padding applied to all sides in mm.

setPadding

public ComponentSelector setPadding(int topBottom, int leftRight)
Sets padding on all components in found set.

Parameters

topBottom int
Top and bottom padding in pixels.
leftRight int
Left and right padding in pixels.

setPaddingPercent

public ComponentSelector setPaddingPercent(double padding)
Sets the padding on all components in found set as a percentage of their respective parents’ dimensions. Horizontal padding is set as a percentage of parent width. Vertical padding is set as a percentage of parent height.

Parameters

padding double
The padding expressed as a percent.

setPaddingPercent

public ComponentSelector setPaddingPercent(double topBottom, double leftRight)
Sets padding on all components in found set as a percentage of their respective parents’ dimensions.

Parameters

topBottom double
Top and bottom padding as percentage of parent heights.
leftRight double
Left and right padding as percentage of parent widths.

setPaddingPercent

public ComponentSelector setPaddingPercent(double top, double right, double bottom, double left)
Sets padding on all components in found set as a percentage of their respective parents’ dimensions.

Parameters

top double
Top padding as percentage of parent height.
right double
Right padding as percentage of parent width.
bottom double
Bottom padding as percentage of parent height.
left double
Left padding as percentage of parent width.

setMargin

public ComponentSelector setMargin(int margin)
Sets margin to all sides of found set components in pixels.

Parameters

margin int
Margin in pixels

setMargin

public ComponentSelector setMargin(int top, int right, int bottom, int left)
Sets margin to all components in found set.

Parameters

top int
Top margin in pixels.
right int
Right margin in pixels
bottom int
Bottom margin in pixels.
left int
Left margin in pixels.

setMargin

public ComponentSelector setMargin(int topBottom, int leftRight)
Sets margin on all components in found set.

Parameters

topBottom int
Top and bottom margin in pixels.
leftRight int
Left and right margin in pixels.

setMarginPercent

public ComponentSelector setMarginPercent(double margin)
Sets the margin on all components in found set as a percentage of their respective parents’ dimensions. Horizontal margin is set as a percentage of parent width. Vertical margin is set as a percentage of parent height.

Parameters

margin double
The margin expressed as a percent.

setMarginPercent

public ComponentSelector setMarginPercent(double topBottom, double leftRight)
Sets margin on all components in found set as a percentage of their respective parents’ dimensions.

Parameters

topBottom double
Top and bottom margin as percentage of parent heights.
leftRight double
Left and right margin as percentage of parent widths.

setMarginPercent

public ComponentSelector setMarginPercent(double top, double right, double bottom, double left)
Sets margin on all components in found set as a percentage of their respective parents’ dimensions.

Parameters

top double
Top margin as percentage of parent height.
right double
Right margin as percentage of parent width.
bottom double
Bottom margin as percentage of parent height.
left double
Left margin as percentage of parent width.

setMarginMillimeters

public ComponentSelector setMarginMillimeters(float top, float right, float bottom, float left)
Sets margin to all components in found set in millimeters.

Parameters

top float
Top margin in mm.
right float
Right margin in mm
bottom float
Bottom margin in mm.
left float
Left margin in mm.

setMarginMillimeters

public ComponentSelector setMarginMillimeters(float topBottom, float leftRight)
Sets margin in millimeters to all components in found set.

Parameters

topBottom float
Top and bottom margin in mm.
leftRight float
Left and right margin in mm.

setMarginMillimeters

public ComponentSelector setMarginMillimeters(float margin)
Sets margin to all components in found set.

Parameters

margin float
Margin applied to all sides in mm.

createProxyStyle

public Style createProxyStyle()
Creates a proxy style to mutate the styles of all component styles in found set.

merge

public ComponentSelector merge(Style style)
Merges style with all styles of components in current found set.

setBgColor

public ComponentSelector setBgColor(int bgColor)
Wraps Style#setBgColor(int)

setAlignment

public ComponentSelector setAlignment(int alignment)
Wraps Style#setAlignment(int)

setBgImage

public ComponentSelector setBgImage(Image bgImage)
Wraps Style#setBgImage(com.codename1.ui.Image)

setBackgroundType

public ComponentSelector setBackgroundType(byte backgroundType)
Wraps Style#setBackgroundType(byte)

setBackgroundGradientStartColor

public ComponentSelector setBackgroundGradientStartColor(int startColor)
Wraps Style#setBackgroundGradientStartColor(int)

setBackgroundGradientEndColor

public ComponentSelector setBackgroundGradientEndColor(int endColor)
Wraps (int)

setBackgroundGradientRelativeX

public ComponentSelector setBackgroundGradientRelativeX(float x)
Wraps Style#setBackgroundGradientRelativeX(float)

setBackgroundGradientRelativeY

public ComponentSelector setBackgroundGradientRelativeY(float y)
Wraps Style#setBackgroundGradientRelativeY(float)

setBackgroundGradientRelativeSize

public ComponentSelector setBackgroundGradientRelativeSize(float size)
Wraps Style#setBackgroundGradientRelativeSize(float)

setFgColor

public ComponentSelector setFgColor(int color)
Wraps Style#setFgColor(int)

setFont

public ComponentSelector setFont(Font f)
Wraps Style#setFont(com.codename1.ui.Font)

setUnderline

public ComponentSelector setUnderline(boolean b)
Wraps Style#setUnderline(boolean)

set3DText

public ComponentSelector set3DText(boolean t, boolean raised)
Wraps boolean)

set3DTextNorth

public ComponentSelector set3DTextNorth(boolean north)
Wraps Style#set3DTextNorth(boolean)

setOverline

public ComponentSelector setOverline(boolean b)
Wraps Style#setOverline(boolean)

setStrikeThru

public ComponentSelector setStrikeThru(boolean b)
Wraps Style#setStrikeThru(boolean)

setTextDecoration

public ComponentSelector setTextDecoration(int textDecoration)
Wraps Style#setTextDecoration(int)

setBgTransparency

public ComponentSelector setBgTransparency(int bgTransparency)
Wraps Style#setBgTransparency(byte)

setOpacity

public ComponentSelector setOpacity(int opacity)
Wraps Style#setOpacity(int)

addStyleListener

public ComponentSelector addStyleListener(StyleListener l)
Wraps Style#addStyleListener(com.codename1.ui.events.StyleListener)

removeStyleListener

public ComponentSelector removeStyleListener(StyleListener l)
Wraps Style#removeStyleListener(com.codename1.ui.events.StyleListener)

removeStyleListeners

public ComponentSelector removeStyleListeners()
Wraps Style#removeListeners()

setBorder

public ComponentSelector setBorder(Border b)
Wraps Style#setBorder(com.codename1.ui.plaf.Border)

setBgPainter

public ComponentSelector setBgPainter(Painter bgPainter)
Wraps Style#setBgPainter(com.codename1.ui.Painter)

setFontSize

public ComponentSelector setFontSize(float size)
Sets the font size of all components in found set. In pixels.

Parameters

size float
Font size in pixels.

setMaterialIcon

public ComponentSelector setMaterialIcon(char icon, float size)
Sets the material icon of all labels in the set.

Parameters

icon char
Material icon to set. See char)
size float
The icon size in millimeters.

Returns

Self for chaining.

setCursor

public ComponentSelector setCursor(int cursor)

setFontSizeMillimeters

public ComponentSelector setFontSizeMillimeters(float sizeMM)
Sets the font size of all components in found set. In millimeters.

Parameters

sizeMM float
Font size in mm.

setFontSizePercent

public ComponentSelector setFontSizePercent(double sizePercentage)
Sets the fonts size of all components in the found set as a percentage of the font size of the components’ respective parents.

Parameters

sizePercentage double
Font size as a percentage of parent font size.

first

public ComponentSelector first()
Returns a set with the first element of the current set, or an empty set if the current set is empty.

Returns

A ComponentSelector with 0 or 1 element.