Class ComponentSelector
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 containermyContainer -
$("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 forDisplay#callSerially(java.lang.Runnable) -
Methods to implement
java.util.Setbecause 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 Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceInterface used for providing callbacks that receive a Component as input.static interfaceInterface used by#map(com.codename1.ui.ComponentSelector.ComponentMapper)to form a new set of components based on the components in one set.static interfaceInterface used by#filter(com.codename1.ui.ComponentSelector.Filter)to form a new set of components based on the components in one set. -
Constructor Summary
ConstructorsConstructorDescriptionComponentSelector(Component... cmps) Creates a component selector that wraps the provided components.ComponentSelector(String selector) Creates a selector that will query the current form.ComponentSelector(String selector, Component... roots) Creates a selector with the provided roots.ComponentSelector(String selector, Collection<Component> roots) Creates a selector with the provided roots.ComponentSelector(Set<Component> cmps) Creates a component selector that wraps the provided components. -
Method Summary
Modifier and TypeMethodDescriptionstatic ComponentSelectorDeprecated.static ComponentSelector$(ActionEvent e) Deprecated.static ComponentSelectorDeprecated.static ComponentSelectorDeprecated.static ComponentSelectorDeprecated.static ComponentSelector$(String selector, Collection<Component> roots) Deprecated.static ComponentSelectorDeprecated.booleanExplicitly adds a component to the result set.Fluent API wrapper for#add(com.codename1.ui.Component)Adds action listener to applicable components in found set.booleanaddAll(Collection<? extends Component> c) Adds all components in the given collection to the result set.addAll(Collection<? extends Component> c, boolean chain) Fluent API wrapper for#addAll(java.util.Collection).WrapsTextField#addDataChangedListener(com.codename1.ui.events.DataChangedListener)Adds drag over listener to all components in found set.Adds a drop listener to all components in found set.Adds a focus listener to all components in found set.Adds long pointer pressed listener to all components in found set.Adds pointer dragged listener to all components in found set.Adds pointer pressed listener to all components in found set.Adds pointer released listener to all components in found set.Adds scroll listener to all components in found set.WrapsStyle#addStyleListener(com.codename1.ui.events.StyleListener)Adds the given tags to all elements in the result set.animateHierarchy(int duration) Animates the hierarchy of containers in this set.animateHierarchy(int duration, SuccessCallback<ComponentSelector> callback) WrapsContainer#animateHierarchy(int).animateHierarchyAndWait(int duration) WrapsContainer#animateHierarchyAndWait(int).animateHierarchyFade(int duration, int startingOpacity) WrapsContainer#animateHierarchyAndWait(int)animateHierarchyFade(int duration, int startingOpacity, SuccessCallback<ComponentSelector> callback) Wrapsint).animateHierarchyFadeAndWait(int duration, int startingOpacity) Wrapsint).animateLayout(int duration) WrapsContainer#animateLayout(int)animateLayout(int duration, SuccessCallback<ComponentSelector> callback) WrapsContainer#animateLayout(int).animateLayoutAndWait(int duration) WrapsContainer#animateLayoutAndWait(int)animateLayoutFade(int duration, int startingOpacity) Animates layout with fade on all containers in this set.animateLayoutFade(int duration, int startingOpacity, SuccessCallback<ComponentSelector> callback) Wrapsint).animateLayoutFadeAndWait(int duration, int startingOpacity) Wrapsint).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.animateUnlayout(int duration, int opacity) Wrapsint, java.lang.Runnable)animateUnlayout(int duration, int opacity, SuccessCallback<ComponentSelector> callback) Wrapsint, java.lang.Runnable)animateUnlayoutAndWait(int duration, int opacity) Wrapsint)Appends a child component to the first container in this set.Append a child element to each container in this set.Appends a child component to the first container in this set.append(Object constraint, ComponentSelector.ComponentMapper mapper) Append a child element to each container in this set.applyRTL(boolean rtl) WrapsContainer#applyRTL(boolean)Returns the first component in this set.<T extends Component>
TasComponent(Class<T> type) Returns the first component in this set.asList()Returns the components of this set as a List.voidclear()Clears the result set.clear(boolean chain) Fluent API wrapper for (@link #clear()}Wrapper forComponent#clearClientProperties().Creates a new set of components consistng of all "closest" ancestors of components in this set which match the provided selector.booleancontains(int x, int y) Returns true if any of the components in the found set contains the provided coordinate.booleanChecks if an object is contained in result set.booleancontainsAll(Collection<?> c) Checks if the result set contains all of the components found in the provided collection.booleanReturns true if any of the containers in the current found set contains the provided component in its subtree.Creates a proxy style to mutate the styles of all component styles in found set.each(ComponentSelector.ComponentClosure closure) Applies the given callback to each component in the set.fadeIn()Fade in this set of components.fadeIn(int duration) Fade in this set of components.fadeIn(int duration, SuccessCallback<ComponentSelector> callback) Fade in this set of components.Fades in this component and blocks until animation is complete.fadeInAndWait(int duration) Fades in this component and blocks until animation is complete.fadeOut()Fades out components in this set.fadeOut(int duration) Fades out components in this set.fadeOut(int duration, SuccessCallback<ComponentSelector> callback) Fades out components in this set.fadeOutAndWait(int duration) Hide the matched elements by fading them to transparent.filter(ComponentSelector.Filter filter) Creates a new set of components formed by filtering the current set using a filter function.Filters the current found set against the given selector.Uses the results of this selector as the roots to create a new selector with the provided selector string.Creates new ComponentSelector with the set of first focusable elements of each of the containers in the current result set.first()Returns a set with the first element of the current set, or an empty set if the current set is empty.Creates new set consisting of the first child of each component in the current set.WrapsContainer#forceRevalidate()Returns a proxy style for all of the "all" styles of the components in this set.Gets the AnimationManager for the components in this set.getClientProperty(String key) Gets a client property from the first component in the set.getComponentAt(int index) This returns a new ComponentSelector which includes a set of all results of callingContainer#getComponentAt(int)on containers in this found set.getComponentAt(int x, int y) Returns new ComponentSelector with the set of all components returned from callingint)in the current found set.Gets the set of all component forms from components in this set.Returns a proxy style for all of the disabled styles of the components in this set.Gets the set of all "parent" components of components in the result set.Returns a proxy style for all of the pressed styles of the components in this set.Returns a proxy style for all of the selected styles of the components in this set.getStyle()Gets a proxy style that wraps the result ofComponent#getStyle()of each component in set.Gets a style object for the given component that can be used to modify the component's styles.getText()Gets the text on the first component in this set that supports this property.Returns a proxy style for all of the unselected styles of the components in this set.growShrink(int duration) WrapsComponent#growShrink(int)WrapsContainer#invalidate()booleanisEmpty()Returns
booleanisHidden()Returns true if first component in this set is hidden.booleanbooleanReturns true if the first component in this set is visible.iterator()Returns the results of this selector.Creates new set consisting of the last child of each component in the current set.WrapsContainer#layoutContainer()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.Merges style with all styles of components in current found set.Creates set of "next" siblings of components in this set.WrapsComponent#paint(com.codename1.ui.Graphics)WrapsComponent#paintBackgrounds(com.codename1.ui.Graphics)WrapsComponent#paintComponent(com.codename1.ui.Graphics)WrapsComponent#paintLockRelease()Creates a new set of components consisting of all of the parents of components in this set.Creates new set of components consisting of all of the ancestors of components in this set which match the provided selector.Creates set of "previous" siblings of components in this set.putClientProperty(String key, Object value) Wrapper forjava.lang.Object)WrapsComponent#refreshTheme()refreshTheme(boolean merge) WrapsComponent#refreshTheme(boolean)remove()Wrapper forComponent#remove().booleanExplicitly removes a component from the result set.Fluent API wrapper for#remove(java.lang.Object).Removes action listeners from components in set.This removes all children from all containers in found set.booleanremoveAll(Collection<?> c) Removes all of the components in the provided collection from the result set.removeAll(Collection<?> c, boolean chain) Fluent API wrapper for#removeAll(java.util.Collection)WrapsTextField#removeDataChangedListener(com.codename1.ui.events.DataChangedListener)Removes drag over listener from all components in found set.Removes a drop listener from all components in found set.Removes focus listener from all components in found set.Removes long pointer pressed listener from all components in found set.REmoves pointer dragged listener from all components in found set.Removes pointer pressed listener from all components in found set.Removes pointer released listener from all components in found set.Removes scroll listener from all components in found set.WrapsStyle#removeStyleListener(com.codename1.ui.events.StyleListener)WrapsStyle#removeListeners()removeTags(String... tags) Removes the given tags from all elements in the result set.repaint()WrapsComponent#repaint()repaint(int x, int y, int w, int h) Wrapsint, int, int)Replaces the matched components within respective parents with replacements defined by the provided mapper.replace(ComponentSelector.ComponentMapper mapper, Transition t) Replaces the matched components within respective parents with replacements defined by the provided mapper.Replaces the matched components within respective parents with replacements defined by the provided mapper.WrapsComponent#requestFocus()booleanretainAll(Collection<?> c) Retains only elements of the result set that are contained in the provided collection.retainAll(Collection<?> c, boolean chain) Fluent API wrapper for#retainAll(java.util.Collection)WrapsContainer#revalidate()WrapsContainer#scrollComponentToVisible(com.codename1.ui.Component)static ComponentSelectorAlias of#$(com.codename1.ui.Component...)static ComponentSelectorAlias of#$(com.codename1.ui.events.ActionEvent)static ComponentSelectorAlias of#$(java.lang.Runnable)static ComponentSelectorAlias of#$(java.lang.String)static ComponentSelectorAlias ofcom.codename1.ui.Component...)static ComponentSelectorselect(String selector, Collection<Component> roots) Alias ofjava.util.Collection)static ComponentSelectorAlias of#$(java.util.Set)Sets the current style to each component's ALL STYLES proxy style.Sets the current style to the disabled style.Sets the current style to the pressed style.Sets the current style to the selected style.Sets the current style to the unselected style.set3DText(boolean t, boolean raised) Wrapsboolean)set3DTextNorth(boolean north) WrapsStyle#set3DTextNorth(boolean)setAlignment(int alignment) WrapsStyle#setAlignment(int)setAutoSizeMode(boolean b) WrapsLabel#setAutoSizeMode(boolean)setBackgroundGradientEndColor(int endColor) Wraps(int)setBackgroundGradientRelativeSize(float size) WrapsStyle#setBackgroundGradientRelativeSize(float)setBackgroundGradientRelativeX(float x) WrapsStyle#setBackgroundGradientRelativeX(float)setBackgroundGradientRelativeY(float y) WrapsStyle#setBackgroundGradientRelativeY(float)setBackgroundGradientStartColor(int startColor) WrapsStyle#setBackgroundGradientStartColor(int)setBackgroundType(byte backgroundType) WrapsStyle#setBackgroundType(byte)setBgColor(int bgColor) WrapsStyle#setBgColor(int)setBgImage(Image bgImage) WrapsStyle#setBgImage(com.codename1.ui.Image)setBgPainter(Painter bgPainter) WrapsStyle#setBgPainter(com.codename1.ui.Painter)setBgTransparency(int bgTransparency) WrapsStyle#setBgTransparency(byte)WrapsStyle#setBorder(com.codename1.ui.plaf.Border)setCellRenderer(boolean cell) WrapsComponent#setCellRenderer(boolean)setCommand(Command cmd) WrapsButton#setCommand(com.codename1.ui.Command)setComponentState(Object state) WrapsComponent#setComponentState(java.lang.Object)setCursor(int cursor) setDirtyRegion(Rectangle rect) Wrapper forComponent#setDirtyRegion(com.codename1.ui.geom.Rectangle)setDisabledIcon(Image icon) WrapsButton#setDisabledIcon(com.codename1.ui.Image)setDisabledStyle(Style style) Sets disabled style of all components in found set.WrapsTextField#setDoneListener(com.codename1.ui.events.ActionListener)setDraggable(boolean draggable) WrapsComponent#setDraggable(boolean)setDropTarget(boolean target) WrapsComponent#setDropTarget(boolean)setEditable(boolean b) WrapsTextArea#setEditable(boolean)setEnabled(boolean enabled) WrapsComponent#setEnabled(boolean)setEndsWith3Points(boolean b) WrapsLabel#setEndsWith3Points(boolean)setFgColor(int color) WrapsStyle#setFgColor(int)setFlatten(boolean f) WrapsComponent#setFlatten(boolean)setFocusable(boolean focus) Sets all components in the found set focusability.WrapsStyle#setFont(com.codename1.ui.Font)setFontSize(float size) Sets the font size of all components in found set.setFontSizeMillimeters(float sizeMM) Sets the font size of all components in found set.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.setGap(int gap) Sets gap.setGrabsPointerEvents(boolean g) WrapsComponent#setGrabsPointerEvents(boolean)setHeight(int height) Wrapper forComponent#setHeight(int)setHidden(boolean b) WrapsComponent#setHidden(boolean)setHidden(boolean b, boolean changeMargin) Wrapsboolean)setHideInPortait(boolean hide) WrapsComponent#setHideInPortrait(boolean)setIcon(char materialIcon) Sets the icon of all elements in this set to a material icon.setIcon(char materialIcon, float size) Sets the icon of all elements in this set to a material icon.Sets the icons of all elements in this set to a material icon.Sets the icon for components in found set.setIconUIID(String uiid) Sets the Icon UIID of elements in found set.setIgnorePointerEvents(boolean ignore) WrapsComponent#setLabelForComponent(com.codename1.ui.Label)WrapsContainer#setLayout(com.codename1.ui.layouts.Layout)setLeadComponent(Component lead) WrapsContainer#setLeadComponent(com.codename1.ui.Component)setLegacyRenderer(boolean b) WrapsLabel#setLegacyRenderer(boolean)setMargin(int margin) Sets margin to all sides of found set components in pixels.setMargin(int topBottom, int leftRight) Sets margin on all components in found set.setMargin(int top, int right, int bottom, int left) Sets margin to all components in found set.setMarginMillimeters(float margin) Sets margin to all components in found set.setMarginMillimeters(float topBottom, float leftRight) Sets margin in millimeters to all components in found set.setMarginMillimeters(float top, float right, float bottom, float left) Sets margin to all components in found set in millimeters.setMarginPercent(double margin) Sets the margin on all components in found set as a percentage of their respective parents' dimensions.setMarginPercent(double topBottom, double leftRight) Sets margin on all components in found set as a percentage of their respective parents' dimensions.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.WrapsLabel#setMask(java.lang.Object)setMaskName(String name) WrapsLabel#setMaskName(java.lang.String)setMaterialIcon(char icon, float size) Sets the material icon of all labels in the set.WrapsComponent#setName(java.lang.String)setOpacity(int opacity) WrapsStyle#setOpacity(int)setOverline(boolean b) WrapsStyle#setOverline(boolean)setPadding(int padding) Sets padding to all sides of found set components in pixels.setPadding(int topBottom, int leftRight) Sets padding on all components in found set.setPadding(int top, int right, int bottom, int left) Sets padding to all components in found set.setPaddingMillimeters(float padding) Sets padding to all components in found set.setPaddingMillimeters(float topBottom, float leftRight) Sets padding in millimeters to all components in found set.setPaddingMillimeters(float top, float right, float bottom, float left) Sets padding to all components in found set in millimeters.setPaddingPercent(double padding) Sets the padding on all components in found set as a percentage of their respective parents' dimensions.setPaddingPercent(double topBottom, double leftRight) Sets padding on all components in found set as a percentage of their respective parents' dimensions.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.setPreferredH(int h) Wrapper forComponent#setPreferredH(int)Wrapper forComponent#setPreferredSize(com.codename1.ui.geom.Dimension)setPreferredW(int w) Wrapper forComponent#setPreferredW(int)setPressedIcon(Image icon) WrapsButton#setPressedIcon(com.codename1.ui.Image)setPressedStyle(Style style) Sets pressed style of all components in found set.setPropertyValue(String key, Object value) Wrapsjava.lang.Object)setRolloverIcon(Image icon) WrapsButton#setRolloverIcon(com.codename1.ui.Image)setRolloverPressedIcon(Image icon) WrapsButton#setRolloverPressedIcon(com.codename1.ui.Image)setRTL(boolean rtl) WrapsComponent#setRTL(boolean)Wrapper forComponent#setSameHeight(com.codename1.ui.Component...).Wrapper forComponent#setSameWidth(com.codename1.ui.Component...).setScrollableX(boolean b) WrapsContainer#setScrollableX(boolean)setScrollableY(boolean b) WrapsContainer#setScrollableY(boolean)setScrollAnimationSpeed(int speed) WrapsComponent#setScrollAnimationSpeed(int)setScrollIncrement(int b) WrapsContainer#setScrollIncrement(int)setScrollOpacityChangeSpeed(int scrollOpacityChangeSpeed) WrapsComponent#setScrollOpacityChangeSpeed(int)setScrollSize(Dimension size) Wrapper forComponent#setScrollSizesetScrollVisible(boolean vis) WrapsComponent#setScrollVisible(boolean)setSelectCommandText(String text) Sets select command text on all components in found set.setSelectedStyle(Style style) Sets selected style of all components in found set.setShiftMillimeters(int b) WrapsLabel#setShiftMillimeters(int)setShiftText(int shift) Sets shift text.setShouldCalcPreferredSize(boolean shouldCalcPreferredSize) WrapsContainer#setShouldCalcPreferredSize(boolean)setShouldLocalize(boolean b) WrapsLabel#setShouldLocalize(boolean)setShowEvenIfBlank(boolean b) WrapsLabel#setShowEvenIfBlank(boolean)Wrapper forComponent#setSize(com.codename1.ui.geom.Dimension)setSmoothScrolling(boolean smooth) WrapsComponent#setSmoothScrolling(boolean)setSnapToGrid(boolean s) WrapsComponent#setSnapToGrid(boolean)setStrikeThru(boolean b) WrapsStyle#setStrikeThru(boolean)setTactileTouch(boolean t) WrapsComponent#setTactileTouch(boolean)setTensileLength(int len) WrapsComponent#setTensileLength(int)Sets the text on all components in found set that support this.setTextDecoration(int textDecoration) WrapsStyle#setTextDecoration(int)setTextPosition(int pos) Sets text position of text.setTickerEnabled(boolean b) WrapsLabel#setTickerEnabled(boolean)Wrapper forComponent#setUIID(java.lang.String)setUnderline(boolean b) WrapsStyle#setUnderline(boolean)setUnselectedStyle(Style style) Sets unselected style of all components in found set.setVerticalAlignment(int valign) Sets vertical alignment of text.setVisible(boolean visible) Wrapper forComponent#setVisible(boolean)setWidth(int width) Wrapper forComponent#setWidth(int)setX(int x) Wrapper forComponent#setX(int)setY(int y) Wrapper forComponent#setY(int)intsize()Returns number of results found.Display the matched elements with a sliding motion.slideDown(int duration) Display the matched elements with a sliding motion.slideDown(int duration, SuccessCallback<ComponentSelector> callback) Display the matched elements with a sliding motion.slideDownAndWait(int duration) Display the matched elements with a sliding motion.slideUp()Hide the matched elements with a sliding motion.slideUp(int duration) Hide the matched components with a sliding motion.slideUp(int duration, SuccessCallback<ComponentSelector> callback) Hide the matched elements with a sliding motion.slideUpAndWait(int duration) Hide the matched elements with a sliding motion.startTicker(long delay, boolean rightToLeft) Wrapsboolean)WrapsLabel#stopTicker()Strips margin and padding from components in found set.Object[]toArray()Returns results as an array.<T> T[]toArray(T[] a) Returns results as an array.toString()Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface Collection
parallelStream, removeIf, streamMethods inherited from interface Set
equals, hashCode, spliterator
-
Constructor Details
-
ComponentSelector
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: Components to add to this selector results.
-
ComponentSelector
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: Components to add to this selector results.
-
ComponentSelector
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
invalid input: 'to ensure that the selector has a tree to walk down. #### Parameters - `selector`: The selector string.' -
ComponentSelector
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: The selector string -
roots: The roots for this selector.
-
-
ComponentSelector
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: The selector string -
roots: The roots for this selector.
-
-
-
Method Details
-
$
Deprecated.Wraps provided components in a ComponentSelector set.
Parameters
cmps: Components to be includd in the set.
Returns
ComponentSelector with specified components.
Deprecated
Use
#select(Component...). -
select
Alias of
#$(com.codename1.ui.Component...)Parameters
cmps
-
$
Deprecated.Creates a ComponentInspector with the source component of the provided event.
Parameters
e: The event whose source component is added to the set.
Returns
A ComponentSelector with a single component - the source of the event.
Deprecated
Use
#select(ActionEvent). -
select
Alias of
#$(com.codename1.ui.events.ActionEvent)Parameters
e
-
$
Deprecated.Wraps
Display#callSerially(java.lang.Runnable)Parameters
r
Returns
Empty ComponentSelector.
Deprecated
Use
#select(Runnable). -
select
Alias of
#$(java.lang.Runnable)Parameters
r
-
$
Deprecated.Creates a new ComponentSelector with the provided set of components.
Parameters
cmps: The components to include in the set.
Returns
ComponentSelector with provided components.
Deprecated
Use
#select(Set). -
select
Alias of
#$(java.util.Set)Parameters
cmps
-
$
Deprecated.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: @param selector A selector string that defines which components to include in the set.
Returns
ComponentSelector with matching components.
Deprecated
Use
#select(String). -
select
Alias of
#$(java.lang.String)Parameters
selector
-
$
Deprecated.Creates a ComponentSelector with the components matched by the provided selector in the provided roots' subtrees.
Parameters
-
selector: Selector string to define which components will be included in the set. -
roots: Roots for the selector to search. Only components within the roots' subtrees will be included in the set.
Returns
ComponentSelector with matching components.
Deprecated
Use
Component...). -
-
select
Alias of
com.codename1.ui.Component...)Parameters
-
selector -
roots
-
-
$
Deprecated.Creates a ComponentSelector with the components matched by the provided selector in the provided roots' subtrees.
Parameters
-
selector: Selector string to define which components will be included in the set. -
roots: Roots for the selector to search. Only components within the roots' subtrees will be included in the set.
Returns
ComponentSelector with matching components.
Deprecated
Use
Collection). -
-
select
Alias of
java.util.Collection)Parameters
-
selector -
roots
-
-
each
Applies the given callback to each component in the set.
Parameters
closure: Callback which will be called once for each component in the set.
Returns
Self for chaining.
-
map
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: @param mapper 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
Creates a new set of components formed by filtering the current set using a filter function.
Parameters
filter: @param 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
Filters the current found set against the given selector.
Parameters
selector: The selector to filter the found set on.
Returns
A new set of elements matching the selector.
-
parent
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: Selector to filter the parent components.
Returns
New set with parents of elements in current set.
-
parents
Creates new set of components consisting of all of the ancestors of components in this set which match the provided selector.
Parameters
selector: The selector to filter the ancestors.
Returns
New set with ancestors of elements in current set.
-
closest
Creates a new set of components consistng of all "closest" ancestors of components in this set which match the provided selector.
Parameters
selector: The selector to use to match the nearest ancestor.
Returns
New set with ancestors of components in current set.
-
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
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
Creates set of "next" siblings of components in this set.
Returns
New ComponentSelector with next siblings of this set.
-
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: The style to apply to the components via animation. -
duration: The duration of the animation (ms) -
callback: Callback to call after animation is complete.
Returns
Self for chaining
See also
- Component#createStyleAnimation(java.lang.String, int)
-
-
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
Fade in this set of components. Prior to calling this, the component visibility should be set to "false".
Parameters
duration: The duration of the fade in.
Returns
Self for chaining.
-
fadeIn
Fade in this set of components. Prior to calling this, the component visibility should be set to "false".
Parameters
-
duration: The duration of the fade in. -
callback: Callback to run when animation completes.
-
-
fadeInAndWait
Fades in this component and blocks until animation is complete.
Returns
Self for chaining.
-
fadeInAndWait
Fades in this component and blocks until animation is complete.
Parameters
duration: 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.
See also
- Component#isVisible()
-
setVisible
Wrapper for
Component#setVisible(boolean)Parameters
visible: 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.
See also
- Component#isHidden()
-
setHidden
Wraps
Component#setHidden(boolean)Parameters
b
-
fadeOut
Fades out components in this set. Uses default duration of 500ms.
Returns
Self for chaining.
-
fadeOut
Fades out components in this set.
Parameters
duration: Duration of animation.
Returns
Self for chaining.
-
fadeOut
Fades out components in this set.
Parameters
-
duration: Duration of animation. -
callback: Callback to run when animation completes.
Returns
Self for chaining.
-
-
slideUp
Hide the matched components with a sliding motion.
Parameters
duration: Duration of animation
Returns
Self for chaining.
-
slideUp
Hide the matched elements with a sliding motion.
Parameters
-
duration: Duration of animation. -
callback: Callback to run when animation completes
Returns
Self for chaining.
-
-
slideUpAndWait
Hide the matched elements with a sliding motion. Blocks until animation is complete.
Parameters
duration: Duration of animation.
Returns
Self for chaining.
-
slideDown
Display the matched elements with a sliding motion. Uses default duration of 500ms
Returns
Self for chaining.
-
slideUp
Hide the matched elements with a sliding motion. Uses default duration of 500ms
Returns
Self for chaining.
-
slideDown
Display the matched elements with a sliding motion.
Parameters
duration: Duration of animation.
Returns
Self for chaining.
-
slideDown
Display the matched elements with a sliding motion.
Parameters
-
duration: Duration of animation. -
callback: Callback to run when animation completes.
Returns
Self for chaining.
-
-
slideDownAndWait
Display the matched elements with a sliding motion. Blocks until animation is complete.
Parameters
duration: Duration of animation.
Returns
Self for chaining.
-
fadeOutAndWait
Hide the matched elements by fading them to transparent. Blocks thread until animation is complete.
Parameters
duration: Duration of animation.
Returns
Self for chaining.
-
replace
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: @param mapper 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
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: @param mapper 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 to use for replacements.
Returns
A new ComponentSelector with the replacement components.
-
-
replaceAndWait
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: @param mapper 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
Returns
A new ComponentSelector with the replacement components.
-
-
find
Uses the results of this selector as the roots to create a new selector with the provided selector string.
Parameters
selector: The selector string.
Returns
A new ComponentSelector with the results of the query.
-
iterator
-
getStyle
Gets a proxy style that wraps the result ofComponent#getStyle()of each component in set. -
getStyle
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: 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
Returns a proxy style for all of the selected styles of the components in this set.
Returns
- Returns:
- Proxy style to easily change properties of the selected styles of all components in this set.
-
setSelectedStyle
Sets selected style of all components in found set. Wraps
Component#setSelectedStyle(com.codename1.ui.plaf.Style)Parameters
style
-
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.
See also
- Component#getSelectedStyle()
-
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.
See also
- Component#getUnselectedStyle()
-
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.
See also
- Component#getPressedStyle()
-
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.
See also
- Component#getDisabledStyle()
-
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.
See also
- Component#getAllStyles()
-
getUnselectedStyle
Returns a proxy style for all of the unselected styles of the components in this set.
Returns
- Returns:
- Proxy style to easily change properties of the unselected styles of all components in this set.
-
setUnselectedStyle
Sets unselected style of all components in found set. Wraps
Component#setUnselectedStyle(com.codename1.ui.plaf.Style)Parameters
style
-
getPressedStyle
Returns a proxy style for all of the pressed styles of the components in this set.
Returns
- Returns:
- Proxy style to easily change properties of the pressed styles of all components in this set.
-
setPressedStyle
Sets pressed style of all components in found set. Wraps
Component#setPressedStyle(com.codename1.ui.plaf.Style)Parameters
style
-
getDisabledStyle
Returns a proxy style for all of the disabled styles of the components in this set.
Returns
- Returns:
- Proxy style to easily change properties of the disabled styles of all components in this set.
-
setDisabledStyle
Sets disabled style of all components in found set. Wraps
Component#setDisabledStyle(com.codename1.ui.plaf.Style)Parameters
style
-
getAllStyles
Returns a proxy style for all of the "all" styles of the components in this set.
Returns
- Returns:
- Proxy style to easily change properties of the "all" styles of all components in this set.
-
size
-
isEmpty
-
contains
-
toArray
-
toArray
-
add
-
append
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 to add to container.
Returns
Self for chaining.
-
append
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.Parameters
-
constraint -
child
-
-
append
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.
Parameters
mapper
-
append
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.
Parameters
-
constraint -
mapper
-
-
add
Fluent API wrapper for
#add(com.codename1.ui.Component)Parameters
-
e: Component to add to set. -
chain: Dummy argument so that this version would have a different signature thanSet#add(java.lang.Object)
Returns
Self for chaining.
-
-
remove
-
remove
Fluent API wrapper for
#remove(java.lang.Object).Parameters
-
o: The component to remove from set. -
chain: Dummy argument so that this version would have a different signature thanSet#remove(java.lang.Object)
Returns
Self for chaining.
-
-
containsAll
Checks if the result set contains all of the components found in the provided collection.
Parameters
c
- Specified by:
containsAllin interfaceCollection<Component>- Specified by:
containsAllin interfaceSet<Component>
-
addAll
Adds all components in the given collection to the result set.
Parameters
c
-
addAll
Fluent API wrapper for
#addAll(java.util.Collection).Parameters
-
c: The set of components to add to this set. -
chain: Dummy argument so that this version would have a different signature than#addAll(java.util.Collection)
Returns
Self for chaining.
-
-
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
Returns the first component in this set. This is useful for single component sets (e.g.
$(new Label()).setFgColor(0xff0000).asComponent(Label.class)).Parameters
-
The: type of component to return -
type: The type of component that is expected to be returned.
Returns
The first component in this set.
-
-
asList
-
retainAll
Retains only elements of the result set that are contained in the provided collection.
Parameters
c
-
retainAll
Fluent API wrapper for
#retainAll(java.util.Collection)Parameters
-
c: The collection to retain. -
chain: Dummy arg.
Returns
Self for chaining.
-
-
removeAll
Removes all of the components in the provided collection from the result set.
Parameters
c
-
removeAll
Fluent API wrapper for
#removeAll(java.util.Collection)Parameters
-
c: Collection with components to remove, -
chain: Dummy arg.
Returns
Self for chaining.
-
-
clear
-
clear
Fluent API wrapper for (@link #clear()}
Parameters
chain: Dummy arg
Returns
Self for chaining.
-
toString
-
addTags
Adds the given tags to all elements in the result set.
Parameters
tags: Tags to add.
Returns
Self for chaining.
-
removeTags
Removes the given tags from all elements in the result set.
Parameters
tags
-
getParent
Gets the set of all "parent" components of components in the result set.
Returns
- Returns:
- New Component selector with respective parents of the components in the current result set.
-
setSameWidth
Wrapper forComponent#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
Wrapper forComponent#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
Wrapper for
Component#clearClientProperties().Returns
Self for Chaining.
-
putClientProperty
Wrapper for
java.lang.Object)Parameters
-
key: Property key -
value: Property value
Returns
Self for chaining.
-
-
getClientProperty
-
setDirtyRegion
Wrapper for
Component#setDirtyRegion(com.codename1.ui.geom.Rectangle)Parameters
rect: Dirty region
Returns
Self for chaining.
-
setX
Wrapper for
Component#setX(int)Parameters
x
-
setY
Wrapper for
Component#setY(int)Parameters
y
-
setWidth
Wrapper for
Component#setWidth(int)Parameters
width
-
setHeight
Wrapper for
Component#setHeight(int)Parameters
height
-
setPreferredSize
Wrapper for
Component#setPreferredSize(com.codename1.ui.geom.Dimension)Parameters
dim
-
setPreferredH
Wrapper for
Component#setPreferredH(int)Parameters
h
-
setPreferredW
Wrapper for
Component#setPreferredW(int)Parameters
w
-
setScrollSize
Wrapper for
Component#setScrollSizeParameters
size
-
setSize
Wrapper for
Component#setSize(com.codename1.ui.geom.Dimension)Parameters
size
-
setUIID
Wrapper for
Component#setUIID(java.lang.String)Parameters
uiid
-
remove
Wrapper forComponent#remove(). This will remove all of the components in the current found set from their respective parents. -
addFocusListener
Adds a focus listener to all components in found set. Wraps
Component#addFocusListener(com.codename1.ui.events.FocusListener)Parameters
l
-
removeFocusListener
Removes focus listener from all components in found set. Wraps
Component#removeFocusListener(com.codename1.ui.events.FocusListener)Parameters
l
-
addScrollListener
Adds scroll listener to all components in found set. Wraps
Component#addScrollListener(com.codename1.ui.events.ScrollListener)Parameters
l
-
removeScrollListener
Removes scroll listener from all components in found set. Wraps
Component#removeScrollListener(com.codename1.ui.events.ScrollListener)Parameters
l
-
setSelectCommandText
Sets select command text on all components in found set. Wraps
Component#setSelectCommandText(java.lang.String)Parameters
text
-
setLabelForComponent
Wraps
Component#setLabelForComponent(com.codename1.ui.Label)Parameters
l
-
paintBackgrounds
Wraps
Component#paintBackgrounds(com.codename1.ui.Graphics)Parameters
g
-
paintComponent
Wraps
Component#paintComponent(com.codename1.ui.Graphics)Parameters
g
-
paint
Wraps
Component#paint(com.codename1.ui.Graphics)Parameters
g
-
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)Parameters
-
x -
y
-
-
setFocusable
Sets all components in the found set focusability. Wraps
Component#setFocusable(boolean)Parameters
focus
-
repaint
WrapsComponent#repaint() -
repaint
Wraps
int, int, int)Parameters
-
x -
y -
w -
h
-
-
setScrollAnimationSpeed
Wraps
Component#setScrollAnimationSpeed(int)Parameters
speed
-
setSmoothScrolling
Wraps
Component#setSmoothScrolling(boolean)Parameters
smooth
-
addDropListener
Adds a drop listener to all components in found set. Wraps
Component#addDropListener(com.codename1.ui.events.ActionListener)Parameters
l
-
removeDropListener
Removes a drop listener from all components in found set. Wraps
Component#removeDropListener(com.codename1.ui.events.ActionListener)Parameters
l
-
addDragOverListener
Adds drag over listener to all components in found set. Wraps
Component#addDragOverListener(com.codename1.ui.events.ActionListener)Parameters
l
-
removeDragOverListener
Removes drag over listener from all components in found set. Wraps
Component#removeDragOverListener(com.codename1.ui.events.ActionListener)Parameters
l
-
addPointerPressedListener
Adds pointer pressed listener to all components in found set. Wraps
Component#addPointerPressedListener(com.codename1.ui.events.ActionListener)Parameters
l
-
addLongPressListener
Adds long pointer pressed listener to all components in found set. Wraps
Component#addLongPressListener(com.codename1.ui.events.ActionListener)Parameters
l
-
removePointerPressedListener
Removes pointer pressed listener from all components in found set. Wraps
Component#removePointerPressedListener(com.codename1.ui.events.ActionListener)Parameters
l
-
removeLongPressListener
Removes long pointer pressed listener from all components in found set. Wraps
Component#removeLongPressListener(com.codename1.ui.events.ActionListener)Parameters
l
-
addPointerReleasedListener
Adds pointer released listener to all components in found set. Wraps
Component#addPointerReleasedListener(com.codename1.ui.events.ActionListener)Parameters
l
-
removePointerReleasedListener
Removes pointer released listener from all components in found set. Wraps
Component#removePointerReleasedListener(com.codename1.ui.events.ActionListener)Parameters
l
-
addPointerDraggedListener
Adds pointer dragged listener to all components in found set. Wraps
Component#addPointerDraggedListener(com.codename1.ui.events.ActionListener)Parameters
l
-
removePointerDraggedListener
REmoves pointer dragged listener from all components in found set. Wraps
Component#removePointerDraggedListener(com.codename1.ui.events.ActionListener)Parameters
l
-
requestFocus
WrapsComponent#requestFocus() -
refreshTheme
WrapsComponent#refreshTheme() -
refreshTheme
Wraps
Component#refreshTheme(boolean)Parameters
merge
-
setCellRenderer
Wraps
Component#setCellRenderer(boolean)Parameters
cell
-
setScrollVisible
Wraps
Component#setScrollVisible(boolean)Parameters
vis
-
setEnabled
Wraps
Component#setEnabled(boolean)Parameters
enabled
-
setName
Wraps
Component#setName(java.lang.String)Parameters
name
-
setRTL
Wraps
Component#setRTL(boolean)Parameters
rtl
-
setTactileTouch
Wraps
Component#setTactileTouch(boolean)Parameters
t
-
setPropertyValue
Wraps
java.lang.Object)Parameters
-
key -
value
-
-
paintLockRelease
WrapsComponent#paintLockRelease() -
setSnapToGrid
Wraps
Component#setSnapToGrid(boolean)Parameters
s
-
isIgnorePointerEvents
public boolean isIgnorePointerEvents() -
setIgnorePointerEvents
-
setFlatten
Wraps
Component#setFlatten(boolean)Parameters
f
-
setTensileLength
Wraps
Component#setTensileLength(int)Parameters
len
-
setGrabsPointerEvents
Wraps
Component#setGrabsPointerEvents(boolean)Parameters
g
-
setScrollOpacityChangeSpeed
Wraps
Component#setScrollOpacityChangeSpeed(int)Parameters
scrollOpacityChangeSpeed
-
growShrink
Wraps
Component#growShrink(int)Parameters
duration
-
setDraggable
Wraps
Component#setDraggable(boolean)Parameters
draggable
-
setDropTarget
Wraps
Component#setDropTarget(boolean)Parameters
target
-
setHideInPortait
Wraps
Component#setHideInPortrait(boolean)Parameters
hide
-
setHidden
Wraps
boolean)Parameters
-
b -
changeMargin
-
-
setComponentState
Wraps
Component#setComponentState(java.lang.Object)Parameters
state
-
setLeadComponent
Wraps
Container#setLeadComponent(com.codename1.ui.Component)Parameters
lead
-
setLayout
Wraps
Container#setLayout(com.codename1.ui.layouts.Layout)Parameters
layout
-
invalidate
WrapsContainer#invalidate() -
setShouldCalcPreferredSize
Wraps
Container#setShouldCalcPreferredSize(boolean)Parameters
shouldCalcPreferredSize
-
applyRTL
Wraps
Container#applyRTL(boolean)Parameters
rtl
-
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. WrapsContainer#removeAll() -
revalidate
WrapsContainer#revalidate() -
forceRevalidate
WrapsContainer#forceRevalidate() -
layoutContainer
WrapsContainer#layoutContainer() -
getComponentAt
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.Parameters
index
Returns
New ComponentSelector with
indexth child of each container in the current found set. -
containsInSubtree
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)Parameters
cmp
-
scrollComponentToVisible
Wraps
Container#scrollComponentToVisible(com.codename1.ui.Component)Parameters
cmp
-
getComponentAt
Returns new ComponentSelector with the set of all components returned from calling
int)in the current found set.Parameters
-
x -
y
Returns
New ComponentSelector with components at the given coordinates.
-
-
setScrollableX
Wraps
Container#setScrollableX(boolean)Parameters
b
-
setScrollableY
Wraps
Container#setScrollableY(boolean)Parameters
b
-
setScrollIncrement
Wraps
Container#setScrollIncrement(int)Parameters
b
-
findFirstFocusable
Creates new ComponentSelector with the set of first focusable elements of each of the containers in the current result set.
Returns
- Returns:
New component selector with first focusable element of each container in current found set.
See also
- Container#findFirstFocusable()
-
animateHierarchyAndWait
Wraps
Container#animateHierarchyAndWait(int).Parameters
duration
-
animateHierarchy
Animates the hierarchy of containers in this set. Wraps
Container#animateHierarchy(int)Parameters
duration
-
animateHierarchy
public ComponentSelector animateHierarchy(int duration, SuccessCallback<ComponentSelector> callback) Wraps
Container#animateHierarchy(int).Parameters
-
duration -
callback
-
-
animateHierarchyFadeAndWait
Wraps
int).Parameters
-
duration -
startingOpacity
-
-
animateHierarchyFade
Wraps
Container#animateHierarchyAndWait(int)Parameters
-
duration: The duration of the animation. -
startingOpacity: The starting opacity.
Returns
Self for chaining.
-
-
animateHierarchyFade
public ComponentSelector animateHierarchyFade(int duration, int startingOpacity, SuccessCallback<ComponentSelector> callback) Wraps
int).Parameters
-
duration -
startingOpacity -
callback
-
-
animateLayoutFadeAndWait
Wraps
int).Parameters
-
duration -
startingOpacity
-
-
animateLayoutFade
Animates layout with fade on all containers in this set. Wraps
int).Parameters
-
duration -
startingOpacity
Returns
Self for chaining.
-
-
animateLayoutFade
public ComponentSelector animateLayoutFade(int duration, int startingOpacity, SuccessCallback<ComponentSelector> callback) Wraps
int).Parameters
-
duration -
startingOpacity -
callback
-
-
animateLayout
Wraps
Container#animateLayout(int)Parameters
duration
-
animateLayout
Wraps
Container#animateLayout(int).Parameters
-
duration -
callback
-
-
animateLayoutAndWait
Wraps
Container#animateLayoutAndWait(int)Parameters
duration
-
animateUnlayout
Wraps
int, java.lang.Runnable)Parameters
-
duration -
opacity
-
-
animateUnlayout
public ComponentSelector animateUnlayout(int duration, int opacity, SuccessCallback<ComponentSelector> callback) Wraps
int, java.lang.Runnable)Parameters
-
duration -
opacity -
callback: Callback to run when animation has completed.
-
-
animateUnlayoutAndWait
Wraps
int)Parameters
-
duration -
opacity
-
-
getAnimationManager
Gets the AnimationManager for the components in this set.
Returns
The AnimationManager for the components in this set.
See also
- Component#getAnimationManager()
-
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
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: The text to set in the componnet.
-
setIcon
Sets the icon for components in found set. Only relevant to Labels, SpanLabels, and SpanButtons, and subclasses thereof.
Parameters
icon
-
setIcon
Sets the icons of all elements in this set to a material icon.
Parameters
-
materialIcon: Material icon charcode. -
style: The style for the icon. -
size: The size for the icon. (in mm)
Returns
Self for chaining.
See also
- FontImage#createMaterial(char, java.lang.String, float)
-
-
setIcon
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: The icon charcode. -
size: The size of the icon (in mm)
Returns
Self for chaining
See also
- FontImage#createMaterial(char, com.codename1.ui.plaf.Style, float)
-
-
setIcon
Sets the icon of all elements in this set to a material icon. This will use the foreground color of the label.
Parameters
materialIcon: The material icon charcode.
Returns
Self for chaining.
-
getComponentForm
Gets the set of all component forms from components in this set.
Returns
New ComponentSelector with forms all components in this set.
-
setVerticalAlignment
Sets vertical alignment of text.
Parameters
valign
See also
- Label#setVerticalAlignment(int)
-
setTextPosition
Sets text position of text. Only relevant to labels.
Parameters
pos
See also
- Label#setTextPosition(int)
-
setIconUIID
Sets the Icon UIID of elements in found set.
Parameters
uiid: The UIID for icons.
Returns
Self for chaining.
Since
7.0
See also
- IconHolder#setIconUIID(java.lang.String)
-
setGap
Sets gap. Only relevant to labels.
Parameters
gap
See also
- Label#setGap(int)
-
setShiftText
Sets shift text. Only relevant to labels.
Parameters
shift
See also
- Label#setShiftText(int)
-
startTicker
Wraps
boolean)Parameters
-
delay -
rightToLeft
-
-
stopTicker
WrapsLabel#stopTicker() -
setTickerEnabled
Wraps
Label#setTickerEnabled(boolean)Parameters
b
-
setEndsWith3Points
Wraps
Label#setEndsWith3Points(boolean)Parameters
b
-
setMask
Wraps
Label#setMask(java.lang.Object)Parameters
mask
-
setMaskName
Wraps
Label#setMaskName(java.lang.String)Parameters
name
-
setShouldLocalize
Wraps
Label#setShouldLocalize(boolean)Parameters
b
-
setShiftMillimeters
Wraps
Label#setShiftMillimeters(int)Parameters
b
-
setShowEvenIfBlank
Wraps
Label#setShowEvenIfBlank(boolean)Parameters
b
-
setLegacyRenderer
Wraps
Label#setLegacyRenderer(boolean)Parameters
b
-
setAutoSizeMode
Wraps
Label#setAutoSizeMode(boolean)Parameters
b
-
setCommand
Wraps
Button#setCommand(com.codename1.ui.Command)Parameters
cmd
-
setRolloverPressedIcon
Wraps
Button#setRolloverPressedIcon(com.codename1.ui.Image)Parameters
icon
-
setRolloverIcon
Wraps
Button#setRolloverIcon(com.codename1.ui.Image)Parameters
icon
-
setPressedIcon
Wraps
Button#setPressedIcon(com.codename1.ui.Image)Parameters
icon
-
setDisabledIcon
Wraps
Button#setDisabledIcon(com.codename1.ui.Image)Parameters
icon
-
addActionListener
Adds action listener to applicable components in found set. Currently this will apply to Buttons, Lists, Sliders, TextAreas, OnOffSwitches, SpanButtons, and subclasses thereof.
Parameters
l
-
removeActionListener
Removes action listeners from components in set.
Parameters
l: The listener to remove
Since
7.0
-
setEditable
Wraps
TextArea#setEditable(boolean)Parameters
b
-
addDataChangedListener
Wraps
TextField#addDataChangedListener(com.codename1.ui.events.DataChangedListener)Parameters
l
-
removeDataChangedListener
Wraps
TextField#removeDataChangedListener(com.codename1.ui.events.DataChangedListener)Parameters
l
-
setDoneListener
Wraps
TextField#setDoneListener(com.codename1.ui.events.ActionListener)Parameters
l
-
setPadding
Sets padding to all sides of found set components in pixels.
Parameters
padding: Padding in pixels
See also
- #getStyle(com.codename1.ui.Component)
-
stripMarginAndPadding
Strips margin and padding from components in found set.
Returns
Self for chaining.
Since
7.0
See also
- Style#stripMarginAndPadding()
-
setPadding
Sets padding to all components in found set.
Parameters
-
top: Top padding in pixels. -
right: Right padding in pixels -
bottom: Bottom padding in pixels. -
left: Left padding in pixels.
See also
- #getStyle(com.codename1.ui.Component)
-
-
setPaddingMillimeters
Sets padding to all components in found set in millimeters.
Parameters
-
top: Top padding in mm. -
right: Right padding in mm -
bottom: Bottom padding in mm. -
left: Left padding in mm.
See also
- #getStyle(com.codename1.ui.Component)
-
-
setPaddingMillimeters
Sets padding in millimeters to all components in found set.
Parameters
-
topBottom: Top and bottom padding in mm. -
leftRight: Left and right padding in mm.
See also
- #getStyle(com.codename1.ui.Component)
-
-
setPaddingMillimeters
Sets padding to all components in found set.
Parameters
padding: Padding applied to all sides in mm.
-
setPadding
Sets padding on all components in found set.
Parameters
-
topBottom: Top and bottom padding in pixels. -
leftRight: Left and right padding in pixels.
-
-
setPaddingPercent
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: The padding expressed as a percent.
-
setPaddingPercent
Sets padding on all components in found set as a percentage of their respective parents' dimensions.
Parameters
-
topBottom: Top and bottom padding as percentage of parent heights. -
leftRight: Left and right padding as percentage of parent widths.
-
-
setPaddingPercent
Sets padding on all components in found set as a percentage of their respective parents' dimensions.
Parameters
-
top: Top padding as percentage of parent height. -
right: Right padding as percentage of parent width. -
bottom: Bottom padding as percentage of parent height. -
left: Left padding as percentage of parent width.
-
-
setMargin
Sets margin to all sides of found set components in pixels.
Parameters
margin: Margin in pixels
See also
- #getStyle(com.codename1.ui.Component)
-
setMargin
Sets margin to all components in found set.
Parameters
-
top: Top margin in pixels. -
right: Right margin in pixels -
bottom: Bottom margin in pixels. -
left: Left margin in pixels.
See also
- #getStyle(com.codename1.ui.Component)
-
-
setMargin
Sets margin on all components in found set.
Parameters
-
topBottom: Top and bottom margin in pixels. -
leftRight: Left and right margin in pixels.
-
-
setMarginPercent
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: The margin expressed as a percent.
-
setMarginPercent
Sets margin on all components in found set as a percentage of their respective parents' dimensions.
Parameters
-
topBottom: Top and bottom margin as percentage of parent heights. -
leftRight: Left and right margin as percentage of parent widths.
-
-
setMarginPercent
Sets margin on all components in found set as a percentage of their respective parents' dimensions.
Parameters
-
top: Top margin as percentage of parent height. -
right: Right margin as percentage of parent width. -
bottom: Bottom margin as percentage of parent height. -
left: Left margin as percentage of parent width.
-
-
setMarginMillimeters
Sets margin to all components in found set in millimeters.
Parameters
-
top: Top margin in mm. -
right: Right margin in mm -
bottom: Bottom margin in mm. -
left: Left margin in mm.
See also
- #getStyle(com.codename1.ui.Component)
-
-
setMarginMillimeters
Sets margin in millimeters to all components in found set.
Parameters
-
topBottom: Top and bottom margin in mm. -
leftRight: Left and right margin in mm.
See also
- #getStyle(com.codename1.ui.Component)
-
-
setMarginMillimeters
Sets margin to all components in found set.
Parameters
margin: Margin applied to all sides in mm.
-
createProxyStyle
Creates a proxy style to mutate the styles of all component styles in found set.
See also
-
#getStyle(com.codename1.ui.Component)
-
Style#createProxyStyle(com.codename1.ui.plaf.Style...)
-
-
merge
Merges style with all styles of components in current found set.
Parameters
style
See also
-
Style#merge(com.codename1.ui.plaf.Style)
-
#getStyle(com.codename1.ui.Component)
-
setBgColor
Wraps
Style#setBgColor(int)Parameters
bgColor
See also
- #getStyle(com.codename1.ui.Component)
-
setAlignment
Wraps
Style#setAlignment(int)Parameters
alignment
See also
- #getStyle(com.codename1.ui.Component)
-
setBgImage
Wraps
Style#setBgImage(com.codename1.ui.Image)Parameters
bgImage
See also
- #getStyle(com.codename1.ui.Component)
-
setBackgroundType
Wraps
Style#setBackgroundType(byte)Parameters
backgroundType
See also
- #getStyle(com.codename1.ui.Component)
-
setBackgroundGradientStartColor
Wraps
Style#setBackgroundGradientStartColor(int)Parameters
startColor
See also
- #getStyle(com.codename1.ui.Component)
-
setBackgroundGradientEndColor
Wraps
(int)Parameters
endColor
See also
- #getStyle(com.codename1.ui.Component)
-
setBackgroundGradientRelativeX
Wraps
Style#setBackgroundGradientRelativeX(float)Parameters
x
See also
- #getStyle(com.codename1.ui.Component)
-
setBackgroundGradientRelativeY
Wraps
Style#setBackgroundGradientRelativeY(float)Parameters
y
See also
- #getStyle(com.codename1.ui.Component)
-
setBackgroundGradientRelativeSize
Wraps
Style#setBackgroundGradientRelativeSize(float)Parameters
size
See also
- #getStyle(com.codename1.ui.Component)
-
setFgColor
Wraps
Style#setFgColor(int)Parameters
color
See also
- #getStyle(com.codename1.ui.Component)
-
setFont
Wraps
Style#setFont(com.codename1.ui.Font)Parameters
f
See also
- #getStyle(com.codename1.ui.Component)
-
setUnderline
Wraps
Style#setUnderline(boolean)Parameters
b
See also
- #getStyle(com.codename1.ui.Component)
-
set3DText
Wraps
boolean)Parameters
-
t -
raised
See also
- #getStyle(com.codename1.ui.Component)
-
-
set3DTextNorth
Wraps
Style#set3DTextNorth(boolean)Parameters
north
See also
- #getStyle(com.codename1.ui.Component)
-
setOverline
Wraps
Style#setOverline(boolean)Parameters
b
See also
- #getStyle(com.codename1.ui.Component)
-
setStrikeThru
Wraps
Style#setStrikeThru(boolean)Parameters
b
See also
- #getStyle(com.codename1.ui.Component)
-
setTextDecoration
Wraps
Style#setTextDecoration(int)Parameters
textDecoration
See also
- #getStyle(com.codename1.ui.Component)
-
setBgTransparency
Wraps
Style#setBgTransparency(byte)Parameters
bgTransparency
See also
- #getStyle(com.codename1.ui.Component)
-
setOpacity
Wraps
Style#setOpacity(int)Parameters
opacity
See also
- #getStyle(com.codename1.ui.Component)
-
addStyleListener
Wraps
Style#addStyleListener(com.codename1.ui.events.StyleListener)Parameters
l
See also
- #getStyle(com.codename1.ui.Component)
-
removeStyleListener
Wraps
Style#removeStyleListener(com.codename1.ui.events.StyleListener)Parameters
l
See also
- #getStyle(com.codename1.ui.Component)
-
removeStyleListeners
Wraps
Style#removeListeners()See also
- #getStyle(com.codename1.ui.Component)
-
setBorder
Wraps
Style#setBorder(com.codename1.ui.plaf.Border)Parameters
b
See also
- #getStyle(com.codename1.ui.Component)
-
setBgPainter
Wraps
Style#setBgPainter(com.codename1.ui.Painter)Parameters
bgPainter
See also
- #getStyle(com.codename1.ui.Component)
-
setFontSize
Sets the font size of all components in found set. In pixels.
Parameters
size: Font size in pixels.
See also
- #getStyle(com.codename1.ui.Component)
-
setMaterialIcon
Sets the material icon of all labels in the set.
Parameters
-
icon: Material icon to set. Seechar) -
size: The icon size in millimeters.
Returns
Self for chaining.
Since
7.0
-
-
setCursor
-
setFontSizeMillimeters
Sets the font size of all components in found set. In millimeters.
Parameters
sizeMM: Font size in mm.
-
setFontSizePercent
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: Font size as a percentage of parent font size.
-
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.
Since
7.0
-