Search in sources :

Example 76 with Label

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

the class SideMenuTest3086 method start.

public void start() {
    if (current != null) {
        current.show();
        return;
    }
    Toolbar.setGlobalToolbar(true);
    Toolbar.setOnTopSideMenu(false);
    Form hi2 = new Form("Hi2 World", BoxLayout.y());
    hi2.add(new Label("Press to show form2"));
    hi2.add(new Button(new Command("show form2") {

        @Override
        public void actionPerformed(ActionEvent evt) {
            try {
                Form hi = new Form("form2");
                Toolbar tb = hi.getToolbar();
                Image icon = theme.getImage("icon.png");
                Container topBar = BorderLayout.east(new Label(icon));
                topBar.add(BorderLayout.SOUTH, new Label("Cool App Tagline...", "SidemenuTagline"));
                topBar.setUIID("SideCommand");
                tb.addComponentToSideMenu(topBar);
                tb.addMaterialCommandToSideMenu("Home", FontImage.MATERIAL_HOME, e -> {
                });
                hi.addComponent(new Label("form2 with sidemenu"));
                // hi.forceRevalidate();
                hi.show();
            } catch (Exception ex) {
                Dialog.show("Error", ex.getMessage(), "OK", null);
                ex.printStackTrace();
            }
        }
    }));
    hi2.show();
}
Also used : Form(com.codename1.ui.Form) Label(com.codename1.ui.Label) IOException(java.io.IOException) Toolbar(com.codename1.ui.Toolbar)

Example 77 with Label

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

the class SocketSample method start.

public void start() {
    if (current != null) {
        current.show();
        return;
    }
    Form hi = new Form("Socket Sample", BoxLayout.y());
    Button server = new Button("Server Sockets");
    Button client = new Button("Client Socket");
    server.addActionListener(evt -> {
        new ServerForm().show();
    });
    client.addActionListener(evt -> {
        new ClientForm().show();
    });
    hi.add(new Label("Select mode")).add(server).add(client);
    hi.show();
}
Also used : Form(com.codename1.ui.Form) Button(com.codename1.ui.Button) Label(com.codename1.ui.Label)

Example 78 with Label

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

the class SpanLabelIconAlignmentTest method start.

public void start() {
    if (current != null) {
        current.show();
        return;
    }
    Form hi = new Form("Hi World", BoxLayout.y());
    FontImage icon = FontImage.createMaterial(FontImage.MATERIAL_FIBER_MANUAL_RECORD, new Label().getStyle(), 30);
    for (String str : text) {
        SpanLabel l = new SpanLabel(str);
        $("*", l).selectAllStyles().setFont(Font.createTrueTypeFont(Font.NATIVE_MAIN_REGULAR).derive(Display.getInstance().convertToPixels(4), Font.STYLE_PLAIN));
        l.setIcon(icon);
        hi.add(l);
    }
    for (String str : text) {
        SpanButton l = new SpanButton(str);
        l.setIcon(icon);
        hi.add(l);
    }
    icon = FontImage.createMaterial(FontImage.MATERIAL_FIBER_MANUAL_RECORD, new Label().getStyle(), 4);
    for (String str : text) {
        SpanLabel l = new SpanLabel(str);
        $("*", l).selectAllStyles().setFont(Font.createTrueTypeFont(Font.NATIVE_MAIN_REGULAR).derive(Display.getInstance().convertToPixels(4), Font.STYLE_PLAIN));
        l.setIcon(icon);
        hi.add(l);
    }
    for (String str : text) {
        SpanLabel l = new SpanLabel();
        // set text after the fact to test different flow
        l.setText(str);
        $("*", l).selectAllStyles().setFont(Font.createTrueTypeFont(Font.NATIVE_MAIN_REGULAR).derive(Display.getInstance().convertToPixels(4), Font.STYLE_PLAIN));
        l.setIcon(icon);
        hi.add(l);
    }
    hi.add(new Label("Hi World"));
    hi.show();
}
Also used : Form(com.codename1.ui.Form) SpanLabel(com.codename1.components.SpanLabel) Label(com.codename1.ui.Label) SpanButton(com.codename1.components.SpanButton) SpanLabel(com.codename1.components.SpanLabel) FontImage(com.codename1.ui.FontImage)

Example 79 with Label

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

the class LinearGradientSample method start.

public void start() {
    if (current != null) {
        current.show();
        return;
    }
    Form hi = new Form("Hi World", new BorderLayout());
    Picker picker = new Picker();
    picker.setStrings("No cycle", "Repeat", "Reflect");
    picker.addActionListener(e -> {
        if ("No cycle".equals(picker.getValue())) {
            cycleMethod = NO_CYCLE;
        } else if ("Repeat".equals(picker.getValue())) {
            cycleMethod = REPEAT;
        } else if ("Reflect".equals(picker.getValue())) {
            cycleMethod = REFLECT;
        }
        hi.repaint();
    });
    hi.add(BorderLayout.NORTH, BoxLayout.encloseY(new SpanLabel("Drag pointer below to generate gradients"), new Label("Gradient Cycle Type:"), picker));
    hi.add(BorderLayout.CENTER, new MyComponent());
    hi.show();
}
Also used : BorderLayout(com.codename1.ui.layouts.BorderLayout) Form(com.codename1.ui.Form) Picker(com.codename1.ui.spinner.Picker) SpanLabel(com.codename1.components.SpanLabel) Label(com.codename1.ui.Label) SpanLabel(com.codename1.components.SpanLabel)

Example 80 with Label

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

the class LoadingTextAnimationSample method showLabelTest.

private void showLabelTest() {
    Form f = new Form("Hello", BoxLayout.y());
    Label l = new Label("placeholder");
    f.add(l);
    LoadingTextAnimation.markComponentLoading(l);
    f.show();
    Timer t = new Timer();
    t.schedule(new TimerTask() {

        public void run() {
            CN.callSerially(() -> {
                LoadingTextAnimation.markComponentReady(l);
            });
        }
    }, 2000);
}
Also used : Timer(java.util.Timer) TimerTask(java.util.TimerTask) Form(com.codename1.ui.Form) SpanLabel(com.codename1.components.SpanLabel) Label(com.codename1.ui.Label)

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