Search in sources :

Example 81 with Label

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

the class MySample method start.

public void start() {
    if (current != null) {
        current.show();
        return;
    }
    Form hi = new Form("Hi World", BoxLayout.y());
    hi.add(new Label("Hi World"));
    hi.show();
}
Also used : Form(com.codename1.ui.Form) Label(com.codename1.ui.Label)

Example 82 with Label

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

the class NativeControlsSample method start.

public void start() {
    if (current != null) {
        current.show();
        return;
    }
    if (false) {
        webviewLoginTest();
        return;
    }
    Form hi = new Form("Hi World", BoxLayout.y());
    hi.add(new Label("Hi World"));
    Label result = new Label();
    NSelect<String> select = new NSelect<>();
    $(select).selectAllStyles().setFont(Font.createTrueTypeFont(Font.NATIVE_MAIN_LIGHT, 4f)).setFgColor(0xff0000).setBgColor(0x00ff00);
    select.setOptions("Red", "Green", "Blue", "Orange");
    select.addSelectionListener((i1, i2) -> {
        result.setText(select.getOption(select.getSelectedIndex()));
        hi.revalidateWithAnimationSafety();
    });
    hi.add(result);
    hi.add(select);
    hi.add("Text fields");
    hi.add("Username:");
    NTextField tf1 = new NTextField(TextField.USERNAME);
    System.out.println("Setting font to main light 15mm");
    tf1.getAllStyles().setFont(Font.createTrueTypeFont(Font.NATIVE_MAIN_LIGHT, 15f));
    System.out.println("Finished setting font");
    tf1.getAllStyles().setFgColor(0x003300);
    tf1.getAllStyles().setBgTransparency(255);
    tf1.getAllStyles().setBgColor(0xcccccc);
    tf1.getAllStyles().setAlignment(CENTER);
    hi.add(tf1);
    hi.add("Password:");
    NTextField tf2 = new NTextField(TextField.PASSWORD);
    hi.add(tf2);
    hi.add("Email:");
    NTextField emailField = new NTextField(TextField.EMAILADDR);
    hi.add(emailField);
    tf1.addActionListener(e -> {
    // tf2.setText(tf1.getText());
    });
    tf1.addChangeListener(e -> {
        result.setText(tf1.getText());
        hi.revalidateWithAnimationSafety();
    });
    tf2.addActionListener(e -> {
        Log.p("Action listener fired on password field");
        result.setText(tf2.getText());
        hi.revalidateWithAnimationSafety();
    });
    tf2.addDoneListener(e -> {
        Log.p("Done was clicked!!!");
    });
    hi.add(new TextField("LW field 1"));
    hi.add(new TextField("LW field 2"));
    hi.add(new TextField("LW field 3"));
    Button submit = new Button("Login");
    submit.addActionListener(e -> {
        Form f = new Form("Logged In", BoxLayout.y());
        Toolbar tb = new Toolbar();
        f.setToolbar(tb);
        tb.setBackCommand(new Command("") {

            @Override
            public void actionPerformed(ActionEvent e) {
                hi.showBack();
            }
        });
        f.add("Logged In!!!");
        f.show();
    });
    hi.add(submit);
    hi.show();
}
Also used : NSelect(com.codename1.nui.NSelect) Form(com.codename1.ui.Form) Button(com.codename1.ui.Button) Command(com.codename1.ui.Command) ActionEvent(com.codename1.ui.events.ActionEvent) Label(com.codename1.ui.Label) TextField(com.codename1.ui.TextField) NTextField(com.codename1.nui.NTextField) NTextField(com.codename1.nui.NTextField) Toolbar(com.codename1.ui.Toolbar)

Example 83 with Label

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

the class ProgressAnimationsSample method start.

public void start() {
    if (current != null) {
        current.show();
        return;
    }
    Form hi = new Form("Hi World", BoxLayout.y());
    hi.add(new Label("Hi World"));
    hi.add(new CommonProgressAnimations.CircleProgress());
    hi.add(new CommonProgressAnimations.LoadingTextAnimation());
    Label labelThatIsLoading = new Label("Loading...");
    hi.add(labelThatIsLoading);
    CommonProgressAnimations.CircleProgress.markComponentLoading(labelThatIsLoading);
    UITimer.timer(2000, false, hi, () -> {
        labelThatIsLoading.setText("Found 248 results");
        CommonProgressAnimations.CircleProgress.markComponentReady(labelThatIsLoading);
    });
    Label anotherLabelThatIsLoading = new Label("Loading...");
    hi.add(anotherLabelThatIsLoading);
    CommonProgressAnimations.CircleProgress.markComponentLoading(anotherLabelThatIsLoading);
    UITimer.timer(4000, false, hi, () -> {
        labelThatIsLoading.setText("Found 512 results");
        CommonProgressAnimations.CircleProgress.markComponentReady(anotherLabelThatIsLoading, CommonTransitions.createFade(300));
    });
    TextArea someText = new TextArea("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.");
    someText.setGrowByContent(true);
    someText.setRows(4);
    someText.setColumns(40);
    someText.setPreferredW(Display.getInstance().getDisplayWidth());
    hi.add(someText);
    CommonProgressAnimations.LoadingTextAnimation.markComponentLoading(someText).cols(40).rows(5);
    UITimer.timer(6000, false, hi, () -> {
        CommonProgressAnimations.CircleProgress.markComponentReady(someText, CommonTransitions.createFade(300));
    });
    hi.show();
}
Also used : Form(com.codename1.ui.Form) TextArea(com.codename1.ui.TextArea) SpanLabel(com.codename1.components.SpanLabel) Label(com.codename1.ui.Label) CommonProgressAnimations(com.codename1.ui.CommonProgressAnimations)

Example 84 with Label

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

the class RTLLayoutAndPadding method start.

public void start() {
    if (current != null) {
        current.show();
        return;
    }
    Form hi = new Form("Hi World", BoxLayout.y());
    Label l = new Label("Hi World");
    FlowLayout fl = new FlowLayout();
    fl.setAlign(CENTER);
    Container row = new Container(fl);
    row.add(new Label("Center"));
    $(row).selectAllStyles().setPaddingMillimeters(3f).setBgColor(0x003366).setBorder(RoundBorder.create());
    hi.add(row);
    fl = new FlowLayout();
    fl.setAlign(RIGHT);
    row = new Container(fl);
    row.add(new Label("Right"));
    $(row).selectAllStyles().setPaddingMillimeters(3f).setBgColor(0x003366).setBorder(RoundBorder.create());
    hi.add(row);
    fl = new FlowLayout();
    fl.setAlign(LEFT);
    row = new Container(fl);
    row.add(new Label("Left"));
    $(row).selectAllStyles().setPaddingMillimeters(3f).setBgColor(0x003366).setBorder(RoundBorder.create());
    hi.add(row);
    fl = new FlowLayout();
    fl.setAlign(CENTER);
    row = new Container(fl);
    row.add(new Label("Center"));
    $(row).selectAllStyles().setPaddingMillimeters(1f, 2f, 1f, 5f).setBgColor(0x003366).setBorder(RoundBorder.create());
    hi.add(row);
    AutoCompleteTextField tf = new AutoCompleteTextField("Red", "Green", "Blue");
    hi.add(FlowLayout.encloseIn(tf));
    hi.show();
}
Also used : Container(com.codename1.ui.Container) AutoCompleteTextField(com.codename1.ui.AutoCompleteTextField) FlowLayout(com.codename1.ui.layouts.FlowLayout) Form(com.codename1.ui.Form) Label(com.codename1.ui.Label)

Example 85 with Label

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

the class RadioButtonLeadComponentTest3105 method start.

public void start() {
    if (current != null) {
        current.show();
        return;
    }
    Form hi = new Form("Lead component breaks ComponentGroup", BoxLayout.y());
    ButtonGroup group = new ButtonGroup();
    ComponentGroup cgroup = new ComponentGroup();
    Label editFieldLabel = new Label("");
    Container visibleField = BorderLayout.centerCenterEastWest(cgroup, editFieldLabel, null);
    RadioButton r1 = new RadioButton("R1");
    group.add(r1);
    cgroup.add(r1);
    RadioButton r2 = new RadioButton("R2");
    group.add(r2);
    cgroup.add(r2);
    hi.add(visibleField);
    ButtonGroup group2 = new ButtonGroup();
    ComponentGroup cgroup2 = new ComponentGroup();
    Label editFieldLabel2 = new Label("EDIT2");
    Container visibleField2 = BorderLayout.centerCenterEastWest(cgroup2, editFieldLabel2, null);
    RadioButton r3 = new RadioButton("R3");
    group2.add(r3);
    cgroup2.add(r3);
    RadioButton r4 = new RadioButton("R4");
    group2.add(r4);
    cgroup2.add(r4);
    hi.add(visibleField2);
    // What causes the problem:
    cgroup2.setBlockLead(true);
    // making the ComponentGroup lead makes it impossible to select the radio buttons
    visibleField2.setLeadComponent(cgroup2);
    hi.show();
}
Also used : Container(com.codename1.ui.Container) ComponentGroup(com.codename1.ui.ComponentGroup) Form(com.codename1.ui.Form) ButtonGroup(com.codename1.ui.ButtonGroup) 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