use of com.codename1.rad.models.Property.Label in project CodenameOne by codenameone.
the class SpanLabelTest2897 method start.
public void start() {
if (current != null) {
current.show();
return;
}
Form hi = new Form("Welcome");
Container container = new Container(BoxLayout.y());
SpanLabel label = new SpanLabel("Span label only shows one row. We need to update the columns for rendering, otherwise it will still wrap at the old number of columns.");
container.add(label);
SpanLabel label1 = new SpanLabel("Set span label text component row count manually. We need to update the columns for rendering, otherwise it will still wrap at the old number of columns.");
// label1.getTextComponent().setRows(4);
container.add(label1);
SpanButton btn = new SpanButton("Hello");
container.add(btn);
btn = new SpanButton("Set span button text component row count manually. We need to update the columns for rendering, otherwise it will still wrap at the old number of columns.");
container.add(btn);
hi.add(container);
hi.show();
}
use of com.codename1.rad.models.Property.Label in project CodenameOne by codenameone.
the class ComponentSelector method parents.
/**
* Creates new set of components consisting of all of the ancestors of components in this set which
* match the provided selector.
* @param selector The selector to filter the ancestors.
* @return New set with ancestors of elements in current set.
*/
public ComponentSelector parents(String selector) {
ComponentSelector matcher = new ComponentSelector(selector, new Label());
LinkedHashSet<Component> matches = new LinkedHashSet<Component>();
for (Component c : this) {
Component parent = c.getParent();
while (parent != null) {
if (matcher.match(parent)) {
matches.add(parent);
}
parent = parent.getParent();
}
}
return matcher.addAll(matches, true);
}
use of com.codename1.rad.models.Property.Label in project CodenameOne by codenameone.
the class ComponentSelector method 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.
* @param materialIcon The icon charcode.
* @param size The size of the icon (in mm)
* @return Self for chaining
* @see FontImage#createMaterial(char, com.codename1.ui.plaf.Style, float)
*/
public ComponentSelector setIcon(char materialIcon, float size) {
for (Component c : this) {
if (c instanceof Label) {
Label l = (Label) c;
Style style = new Style();
Style cStyle = c.getUnselectedStyle();
style.setBgTransparency(0);
style.setFgColor(cStyle.getFgColor());
l.setIcon(FontImage.createMaterial(materialIcon, style, size));
if (c instanceof Button) {
Button b = (Button) c;
style = new Style();
cStyle = c.getPressedStyle();
style.setBgTransparency(0);
style.setFgColor(cStyle.getFgColor());
b.setPressedIcon(FontImage.createMaterial(materialIcon, style, size));
}
}
}
return this;
}
use of com.codename1.rad.models.Property.Label in project CodenameOne by codenameone.
the class ComponentSelector method 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.
* @param selector Selector to filter the parent components.
* @return New set with parents of elements in current set.
*/
public ComponentSelector parent(String selector) {
ComponentSelector matcher = new ComponentSelector(selector, new Label());
LinkedHashSet<Component> matches = new LinkedHashSet<Component>();
for (Component c : this) {
Component parent = c.getParent();
if (parent != null && matcher.match(parent)) {
matches.add(parent);
}
}
return matcher.addAll(matches, true);
}
use of com.codename1.rad.models.Property.Label in project CodenameOne by codenameone.
the class ComponentSelector method closest.
/**
* Creates a new set of components consistng of all "closest" ancestors of components
* in this set which match the provided selector.
* @param selector The selector to use to match the nearest ancestor.
* @return New set with ancestors of components in current set.
*/
public ComponentSelector closest(String selector) {
ComponentSelector matcher = new ComponentSelector(selector, new Label());
LinkedHashSet<Component> matches = new LinkedHashSet<Component>();
for (Component c : this) {
Component parent = c.getParent();
while (parent != null) {
if (matcher.match(parent)) {
matches.add(parent);
break;
}
parent = parent.getParent();
}
}
return matcher.addAll(matches, true);
}
Aggregations