Search in sources :

Example 71 with Label

use of com.codename1.rad.models.Property.Label in project CodenameOne by codenameone.

the class GenericListCellRenderer method setComponentValueWithTickering.

private void setComponentValueWithTickering(Component cmp, Object value, Component l, Component rootRenderer) {
    setComponentValue(cmp, value, l, rootRenderer);
    if (cmp instanceof Label) {
        if (selectionListener) {
            if (l instanceof List) {
                ((List) l).addActionListener(mon);
            }
            parentList = l;
        }
        Label label = (Label) cmp;
        if (label.shouldTickerStart() && Display.getInstance().shouldRenderSelection()) {
            if (!label.isTickerRunning()) {
                parentList = l;
                if (parentList != null) {
                    Form f = parentList.getComponentForm();
                    if (f != null) {
                        f.registerAnimated(mon);
                        label.startTicker(cmp.getUIManager().getLookAndFeel().getTickerSpeed(), true);
                    }
                }
            }
        } else {
            if (label.isTickerRunning()) {
                label.stopTicker();
            }
            label.setTextPosition(0);
        }
    }
}
Also used : Form(com.codename1.ui.Form) Label(com.codename1.ui.Label) List(com.codename1.ui.List) ArrayList(java.util.ArrayList)

Example 72 with Label

use of com.codename1.rad.models.Property.Label in project CodenameOne by codenameone.

the class ImageViewerTest2679 method start.

public void start() {
    if (current != null) {
        current.show();
        return;
    }
    Form f = new Form(new LayeredLayout());
    f.setScrollableY(false);
    f.setScrollableX(false);
    f.getContentPane().setScrollableY(false);
    f.getContentPane().setScrollableX(false);
    ImageViewer viewer = new ImageViewer();
    viewer.setAllowScaleDown(true);
    viewer.setImageInitialPosition(ImageViewer.IMAGE_FILL);
    ListModel images = new DefaultListModel();
    final int w = 724;
    final int h = 1024;
    for (int i = 0; i < 10; i++) {
        Image placeholder = Image.createImage(w, h);
        Image img = URLImage.createCachedImage("experimentImage", "https://media.istockphoto.com/vectors/decorative-black-rectangular-frame-for-label-certificate-card-a3-a4-vector-id1039615844", placeholder, URLImage.FLAG_RESIZE_SCALE);
        images.addItem(img);
    }
    f.addComponent(viewer);
    viewer.setImageList(images);
    f.show();
}
Also used : Form(com.codename1.ui.Form) ListModel(com.codename1.ui.list.ListModel) DefaultListModel(com.codename1.ui.list.DefaultListModel) DefaultListModel(com.codename1.ui.list.DefaultListModel) LayeredLayout(com.codename1.ui.layouts.LayeredLayout) Image(com.codename1.ui.Image) URLImage(com.codename1.ui.URLImage) ImageViewer(com.codename1.components.ImageViewer)

Example 73 with Label

use of com.codename1.rad.models.Property.Label in project CodenameOne by codenameone.

the class InfiniteContainerSafeAreaTest method start.

public void start() {
    if (current != null) {
        current.show();
        return;
    }
    Form hi = new Form("InfiniteContainer", new BorderLayout());
    Style s = UIManager.getInstance().getComponentStyle("MultiLine1");
    FontImage p = FontImage.createMaterial(FontImage.MATERIAL_PORTRAIT, s);
    EncodedImage placeholder = EncodedImage.createFromImage(p.scaled(p.getWidth() * 3, p.getHeight() * 3), false);
    InfiniteContainer ic = new InfiniteContainer() {

        @Override
        public Component[] fetchComponents(int index, int amount) {
            java.util.List<Map<String, Object>> data = fetchPropertyData("Leeds");
            MultiButton[] cmps = new MultiButton[data.size()];
            for (int iter = 0; iter < cmps.length; iter++) {
                Map<String, Object> currentListing = data.get(iter);
                if (currentListing == null) {
                    return null;
                }
                String thumb_url = (String) currentListing.get("thumb_url");
                String guid = (String) currentListing.get("guid");
                String summary = (String) currentListing.get("summary");
                cmps[iter] = new MultiButton(summary);
            // cmps[iter].setIcon(URLImage.createToStorage(placeholder, guid, thumb_url));
            }
            return cmps;
        }
    };
    ic.setUIID("Blue");
    ic.setSafeArea(true);
    ic.addComponent(new Label("This is a test"));
    hi.add(BorderLayout.CENTER, ic);
    hi.show();
}
Also used : Form(com.codename1.ui.Form) Label(com.codename1.ui.Label) Style(com.codename1.ui.plaf.Style) MultiButton(com.codename1.components.MultiButton) HashMap(java.util.HashMap) Map(java.util.Map)

Example 74 with Label

use of com.codename1.rad.models.Property.Label in project CodenameOne by codenameone.

the class LandscapeToolbarHiddenSample method start.

public void start() {
    if (current != null) {
        current.show();
        return;
    }
    Form hi = new Form("Test 2387", BoxLayout.y());
    hi.add(new Label("Hi World"));
    if (!CN.isPortrait()) {
        hi.getToolbar().hideToolbar();
    }
    Button hide = new Button("Hide");
    Button show = new Button("Show");
    hide.addActionListener(e -> hi.getToolbar().hideToolbar());
    show.addActionListener(e -> hi.getToolbar().showToolbar());
    hi.addOrientationListener(e -> {
        if (CN.isPortrait()) {
            hi.getToolbar().showToolbar();
        } else {
            hi.getToolbar().hideToolbar();
        }
    });
    hi.addAll(hide, show);
    hi.show();
}
Also used : Form(com.codename1.ui.Form) Button(com.codename1.ui.Button) Label(com.codename1.ui.Label)

Example 75 with Label

use of com.codename1.rad.models.Property.Label in project CodenameOne by codenameone.

the class SearchCommandTextHintSample2953 method start.

public void start() {
    if (current != null) {
        current.show();
        return;
    }
    Form hi18 = new Form("FormTitle");
    hi18.setLayout(BoxLayout.y());
    Container cont18 = hi18.getContentPane();
    hi18.getToolbar().addSearchCommand((e) -> {
        String text = (String) e.getSource();
        for (Component c : hi18.getContentPane()) {
            c.setHidden(c instanceof Label && ((Label) c).getText().indexOf(text) < 0);
        }
        hi18.getComponentForm().animateLayout(150);
    });
    for (int i = 0; i < 20; i++) {
        Label l = new Label("Label " + i);
        cont18.add(l);
    }
    hi18.show();
}
Also used : Container(com.codename1.ui.Container) Form(com.codename1.ui.Form) Label(com.codename1.ui.Label) Component(com.codename1.ui.Component)

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