Search in sources :

Example 91 with Label

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();
}
Also used : Container(com.codename1.ui.Container) Form(com.codename1.ui.Form) SpanButton(com.codename1.components.SpanButton) SpanLabel(com.codename1.components.SpanLabel)

Example 92 with Label

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);
}
Also used : LinkedHashSet(java.util.LinkedHashSet) SpanLabel(com.codename1.components.SpanLabel)

Example 93 with Label

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;
}
Also used : SpanButton(com.codename1.components.SpanButton) SpanLabel(com.codename1.components.SpanLabel) Style(com.codename1.ui.plaf.Style)

Example 94 with Label

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);
}
Also used : LinkedHashSet(java.util.LinkedHashSet) SpanLabel(com.codename1.components.SpanLabel)

Example 95 with Label

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);
}
Also used : LinkedHashSet(java.util.LinkedHashSet) SpanLabel(com.codename1.components.SpanLabel)

Aggregations

Label (com.codename1.ui.Label)129 Form (com.codename1.ui.Form)95 Button (com.codename1.ui.Button)50 BorderLayout (com.codename1.ui.layouts.BorderLayout)50 Container (com.codename1.ui.Container)49 Component (com.codename1.ui.Component)27 SpanLabel (com.codename1.components.SpanLabel)26 Style (com.codename1.ui.plaf.Style)24 BoxLayout (com.codename1.ui.layouts.BoxLayout)19 TextArea (com.codename1.ui.TextArea)18 ActionEvent (com.codename1.ui.events.ActionEvent)18 IOException (java.io.IOException)18 Image (com.codename1.ui.Image)17 Dimension (com.codename1.ui.geom.Dimension)16 TextField (com.codename1.ui.TextField)15 ActionListener (com.codename1.ui.events.ActionListener)15 LayeredLayout (com.codename1.ui.layouts.LayeredLayout)15 Toolbar (com.codename1.ui.Toolbar)13 FlowLayout (com.codename1.ui.layouts.FlowLayout)12 EncodedImage (com.codename1.ui.EncodedImage)11